OSETC TECH

CentOS 7 /Linux: How To Install/Enable Iptables Firewall

In the latest CentOS 7 version, the default firewall was changed as firewalld instead of iptables firewall. Maybe someone still like to use iptables firewall. In this post you will see how to install iptables firewall and enable it and how to stop firewalld service and disable firewalld service? how to remove the firewalld firewall?

CentOS 7 Disable Firewalld Firewall

Firstly, you should stop  firewalld service , issue the following command:

$ sudo systemctl stop firewalld.service

Output:

[devops@devops Desktop]$ sudo systemctl stop firewalld.service

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.

#2) Think before you type.

#3) With great power comes great responsibility.

[sudo] password for devops:

Then disabling firewalld service start automatically while system booting up, issue the following command:

$sudo systemctl disable firewalld.service

Output:

[devops@devops Desktop]$ sudo systemctl disable firewalld.service

rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

rm '/etc/systemd/system/basic.target.wants/firewalld.service'

[devops@devops Desktop]$

If you do not use the firewalld firewall later, then you can remove it directly, issue the following command:

$sudo yum remove firewalld -y

CentOS 7  Iptables Firewall Installation

Install iptables package using the following command:

$sudo yum install iptables-services

Set iptables serivce startup automatically while system booting up, issue the following command:

$sudo systemctl enable iptables

if you want to use command “/etc/init.d/iptables save” to save the firewall policy , you need to update the iptables init script. issue the following command:

$sudo cp /usr/libexec/iptables/iptables.init /etc/init.d/iptables

now you can use “/etc/init.d/iptables save ” command.

$sudo /etc/init.d/iptables save

done…..