How do I 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

   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.
To list iptables rules use following command.

# iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment