How we replace firewalld with iptables on Centos 7

Attacks with bots and Malware applications on the websites are the order of the day, and the companies that offer security solutions Try hard to keep up and do to everyday challenges.
Besides the complex software applications, able to identify, analyze and block automatically computer attacks On a web server, there are also manual solutions through which the IPs of the attacks can be blocked.

Starting with Centos 7, has been entered by defaultFirewallD as a utility system of administration for Firewall.
Firewalld is a complete firewall solution that can be configured and rolled through command lines Firewall-cmd. Not all server administrators are familiar with the Firewalld syntax and prefer iptables Instead of this utility.

How we replace firewalld with iptables on Centos 7

First of all we have to have access with Administrator privileges on the operating system. Preferably directly logged in with “root” in terminal or through SSH.

1. We stop running Firewalld service on Centos 7 executing the command line:

sudo systemctl stop firewalld

2. We disable the automatic start of Firewalld after the system restart:

sudo systemctl disable firewalld

3. We mask the Firewalld service to prevent it from starting by another process:

sudo systemctl mask --now firewalld

After this step, the Firewalld service was completely stopped and deactivated on Centos 7.

Installation and IPTABLS TRUE on Centos 7

The first step is to install the IPTABLS service on Centos 7.

1. We run the command line for installation iptables-services:

sudo yum install iptables-services

2. We start the IPTABLS services for IPV4 and IPV6:

sudo systemctl start iptables
sudo systemctl start ip6tables

3. We activate the automatic start of the IPTABLS service when starting the operating system:

sudo systemctl enable iptables
sudo systemctl enable ip6tables

4. We check if the IPTABLES service runs properly:

sudo systemctl status iptables
sudo systemctl status ip6tables

The above order should return the result:

● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
   Active: active (exited) since Thu 2020-07-09 07:02:51 UTC; 21min ago
 Main PID: 13765 (code=exited, status=0/SUCCESS)

Jul 09 07:02:51 server.name systemd[1]: Starting IPv4 firewall with iptables...
Jul 09 07:02:51 server.name iptables.init[13765]: iptables: Applying firewall rules: [  OK  ]
Jul 09 07:02:51 server.name systemd[1]: Started IPv4 firewall with iptables.

5. We check the rules in iptables with order linnia:

sudo iptables -nvL
sudo ip6tables -nvL

If you have arrived in this point, you have the service Firewalld off and disabled, and in his place is installed iptables, care runs properly and can be administered by command syntax specific.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. How we replace firewalld with iptables on Centos 7
Leave a Comment