To install iptables firewall on Redhat or CentOS Linux, you need to use the following steps:
- Install iptables package:
$ sudo yum install iptables-services
- Enable iptables service at boot time:
sudo systemctl enable iptables
- Start iptables service:
$ sudo systemctl start iptables
- 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
- 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.