Installing iptables on CentOS/RHEL 7/8

In this article, you will learn about the installation of the iptables on CentOS/RHEL 7/8?

The firewalld is the default firewall management tool, but if you want to use iptables, you can do it. The firewalld is the complete package for firewalls in Centos 7 and Centos 8 and the same for RHEL 7 and RHEL 8. If you want to read more about firewalld, you can go on this link Firewalld configuration on Centos 7 /8 and RHEL 7/8.

If you are very much familiar with the iptables command and syntax, then you can install it. To use the iptables, it is good practice to disable the firewalld.


  • You must log-in with a root user or a user with sudo privilege to make the changes.
  • You have a CentOS/RHEL 7/8 system.
  • Access to the command-line.

Step 1: Disabling the firewalld

Firstly, we are going to stop the firewalld service. So, use the below command for that.

sudo systemctl stop firewalld

Secondly, we are going to disable the firewalld service with the help of the below command.

sudo systemctl disable firewalld

Thirdly, we are going to mask the firewalld service so it will not be invoked by any other program.

sudo systemctl mask --now firewalld

As a result, you can see in the below picture,

Step 2: Installing the iptables

As we have disabled the firewalld, we are going to install iptables and use the below command for that.

sudo yum install iptables-services -y

Step 3: Starting the iptables services

It is time to start the services. So you can use the below command.

sudo systemctl start iptables
sudo systemctl start ip6tables

Enabling the service to run on startup,

sudo systemctl enable iptables
sudo systemctl enable ip6tables

So, we have installed and started the services, now it is time to check the status of the iptables service. You can find the below command useful for that.

sudo systemctl status iptables
sudo systemctl status ip6tables

Step 4: Checking current rules

To confirm the current iptables rules, we are going to use the following command.

sudo iptables -nvL
sudo ip6tables -nvL


In this tutorial, you learned to disable the firewalld service and, then you learned to install and enable iptables service in Linux. I am also writing more in-depth about iptables. I hope you understand, but again, if you have any questions, you can ask in the comment section.

Also, for further reading,

Leave a Reply

Your email address will not be published.