Install and enable Iptables firewall on CentOS 7 Linux

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

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
Install iptables on CentOS 7
Install iptables on CentOS 7

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!


  1. 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. 

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button