How to install/enable iptables on CentOS 7

On CentOS 7, FirewallD a default firewall management tool is enabled. In order to install iptables , we need FirewallD from server: # systemctl stop firewalld # systemctl disable firewalld # systemctl mask --now…

All Articles

On CentOS 7, FirewallD a default firewall management tool is enabled.

In order to install iptables, we need FirewallD from server:

# systemctl stop firewalld

# systemctl disable firewalld

# systemctl mask --now firewalld

Once the FirewallD ins disabled, you can proceed to install iptables:

# yum install iptables-services

# systemctl start iptables

# systemctl start iptables6

Enable the iptables to start on boot:

# systemctl enable iptables

# systemctl enable iptables6

To check current iptables rules:

# iptables -nvL

By default, only port 22 is opened in iptables. You can now open other ports like 80, 53, 25, 587 etc. for the services you install.

Published by

anup

Technical content from the 24x7ServerSupport infrastructure, server management and cloud operations team.