There is no way to permanently add firewall rules in the Linux
machine. But, one can make some changes so that whenever Linux is booting up it will load firewall rules which are already stored in some file.
It can be achieved using iptables-save and iptables-restore to save and restore firewall rules.
First, execute all the IPTable rules on the CentOS machine.
Then save IPTable rules to some file like
It can be achieved using iptables-save and iptables-restore to save and restore firewall rules.
First, execute all the IPTable rules on the CentOS machine.
Then save IPTable rules to some file like
/etc/iptables.conf using the following command:$ iptables-save > /etc/iptables.conf
Add the following command in /etc/rc.local to reload the rules in every reboot.$ iptables-restore < /etc/iptables.conf
After executing the above command change the permissions of rc.local to executable.
To check whether it is restoring the firewall rules or not, remove the firewall rules
and restart the system. If the firewall rules which you stored usingiptables-save > /etc/iptables.conf
are present then it is working. Otherwise, repeat the above steps.
Comments
Post a Comment