How to Install and Use Iptables on CentOS/RHEL 7

How to Install and Use Iptables on CentOS/RHEL 7

Latest Linux operating systems like CentOS/RedHat 7 and Fedora 21 has stop using iptables and start now using dynamic firewall daemon firewalld which provides a dynamically managed firewall. It supports for network and zones to assign a level of trust to a network, connections and interfaces. Firewalld also provides and interface for services or applications to add firewall rules directly. This article will help you to disable firewalld service and then install and use iptables on CentOS and Red Hat 7 Systems. Visit here to read more about firewalld.

Disable Firewalld Service

Before installing and using iptables services on CentOS and Red Hat 7 systems, we need to disable firewalld service. To completely disable firewalld service use following commands.

# systemctl stop firewalld
# systemctl mask firewalld

Now check firewalld status

# systemctl status firewalld


firewalld.service
   Loaded: masked (/dev/null)
   Active: inactive (dead) since Fri 2015-02-27 11:09:37 EST; 56s ago
 Main PID: 7411 (code=exited, status=0/SUCCESS)

Feb 27 11:02:18 svr10 systemd[1]: Started firewalld - dynamic firewall daemon.
Feb 27 11:09:36 svr10 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Feb 27 11:09:37 svr10 systemd[1]: Stopped firewalld - dynamic firewall daemon.

Install Iptables Service in CentOS/RHEL 7

Now install iptables service using yum package manager using following command.

# yum install iptables-services -y

After installing enable iptables service and start using below commands.

# systemctl enable iptables
# systemctl start iptables

Now check the iptables service status using below command.

# systemctl status iptables


iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)
   Active: active (exited) since Fri 2015-02-27 11:14:12 EST; 14s ago
  Process: 7938 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
 Main PID: 7938 (code=exited, status=0/SUCCESS)

Feb 27 11:14:12 svr10 iptables.init[7938]: iptables: Applying firewall rules: [  OK  ]
Feb 27 11:14:12 svr10 systemd[1]: Started IPv4 firewall with iptables.

 
Enjoyed this video?
How to Install and Use Iptables on CentOS/RHEL 7
"No Thanks. Please Close This Box!"