In this tutorial we will show you how to install and enable an iptables firewall on CentOS 7 Linux.
First, need to disable and remove firewalld firewall. Type Following commands:
sudo systemctl stop firewalld.service sudo systemctl disable firewalld.service yum remove firewalld -y
[ads]
Install iptables firewall on CentOS 7
To install Iptables package type following command:
yum install iptables-service -y
After install iptables firewall, set the iptables service to start automatically with system booting up:
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:
cp /usr/libexec/iptables/iptables.init /etc/init.d/iptables
now you can use “/etc/init.d/iptables save ” command.
/etc/init.d/iptables save
That’s been all!
Doesn’t systemd handle this in CentOS 7?
Because you can. And because some people prefer good-old iptables over firewalld.
I thought Firewalld was a wrapper for iptables?
https://fedoraproject.org/wiki/FirewallD
Why bother when firewalld is installed on CentOS 7? They are both just interfaces to the netfilter kernel code, so one isn’t doing anything the other can’t do.
Excellent tip! Thank you!