Skip to content Skip to sidebar Skip to footer

How to Make Persistent Iptables Firewall on Linux


iptables-save and iptables-restore commands are used to export to file and importing tables from data being specified on the STDIN or from a file. We can use I/O redirection provided by default shell to read from a file or specify the file as an argument.

Usually, iptables configuration on Linux will lost after reboot. We can use this method to make the configuration persistent.




Saving Firewall Tables to a File
For example, go to /root then create a folder named iptables. execute command 
sudo iptables-save > /root/iptables/iptables.txt


To make sure the configuration saved correctly, you can open the file using any text editor or simply just run command cat /root/iptables/iptables.txt

Restore Firewall Tables from a File
Just simply run sudo iptables-restore < /root/iptables/iptables.txt then all the configuration on the iptables.txt will be restored to the firewall.

We can put this command on the /etc/rc.local to make all the firewall settings loaded during system startup. So you don't need to worry from losing firewall settings after reboot.



Post a Comment for "How to Make Persistent Iptables Firewall on Linux "