Skip to content
TrySitePrice

Install Iptables Firewall in Redhat / CentOS Linux

Best/Tutorial

To install iptables firewall on Redhat or CentOS Linux, you need to use the following steps:

  1. Install iptables package:

$ sudo yum install iptables-services

  1. Enable iptables service at boot time:

$ sudo systemctl enable iptables

  1. Start iptables service:

$ sudo systemctl start iptables

  1. Configure iptables rules: The iptables firewall rules can be set using the iptables command. You can use the following commands to configure the firewall rules:

# To list the existing iptables rules:

$ sudo iptables -L

# To add a new rule to allow incoming ssh traffic:

$ sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# To save the iptables rules:

$ sudo service iptables save

  1. Restart iptables service after saving the rules:

$ sudo systemctl restart iptables

Note: You can also use other firewall management tools such as firewalld, UFW, etc., depending on your Linux distribution.