How to Install Iptables on CentOS 7

You may already know that CentOS 7 use Firewalld as the front end interface to manage netfilter firewall and not Iptables.

So the purpose of this tutorial is to learn how to install and configure Iptables on CentOS 7 Linux, since many of the Linux system administrators still prefer Iptables over Firewalld. So do the following steps.

Step One

Install Iptables on CentOS 7

First, we need to install Iptables because it is not there by default with the latest CentOS 7 release. But we can easily install Iptables with the yum software manager.

yum install iptables-services

Step Two

Disable Firewalld Service

We cannot have two front end interface to manage netfilter firewall rules because it does not work that way. So we need to disable CentOS 7 Firewalld Service first. Just execute the following commands in the terminal

systemctl stop firewalld.service

systemctl disable firewalld.service

systemctl mask firewalld.service

Step Three

Start and Enable Iptables

Last step is to start and enable Iptables for both IPv4 and IPv6. To do that execute the following commands in the terminal

systemctl start iptables.service

systemctl enable iptables.service

systemctl start ip6tables.service

systemctl enable ip6tables.service

Now just like CentOS 6, you can find the main configuration file inside the /etc/sysconfig Directory.