How to set up iptables to restore automatically on reboot in CentOS Linux?

After setting up the iptables rules check them!
iptables -S

At this stage your iptables rules should be showing.

 

Next iptables needs to be installed as a service and then the iptables service needs to be started on reboot. Then rules need to be saved so that they persist on reboot

 

Change to root

su

 

Install ‘iptables-services’ package

yum install iptables-services

 

Enable iptables as a system service

systemctl enable iptables

 

Enable iptables service to start on system startup

systemctl start iptables

 

Save the iptables rules

service iptables save

 

Reboot the Centos Linux system and check that the iptables rules persist.

Leave a Reply