I am using GUI tool to setup firewall rules for my home computer connected to ADSL (DSL/Cable) network. However, after reboot my rules are not saved. Is there any way I can save and load all firewall rules again?
You need to use the iptables-save command, which is used to dump the contents of an IP Table in easily parseable format to screen. Using I/O-redirection provided by your shell you can save iptables firewall rules to a file.
To restore iptables rules use the iptables-restore command. It is used to restore an IP Tables from data specified from file. Use I/O redirection provided by your shell to read from a file.
Examples: Saving and Restoring Iptables Rules
In this example, save current iptables firewall rules to a file called
# iptables-save > /root/dsl.fw
To restore iptables rules, enter:
# iptables-restore < /root/dsl.fw
To restore rules automatically upon Linux system reboot add following command to your
/etc/rc.local file, enter:
# vi /etc/rc.local
Append the line:
/sbin/iptables-restore < /root/dsl.fw
Save and close the file. Please note that under Red Hat enterprise Linux (RHEL) / CentOS / Fedora Linux you can use following commands to save and restore firewall rules. To Save the rules to /etc/sysconfig/iptables file:
# /etc/init.d/iptables save
To restore the rules from /etc/sysconfig/iptables file:
# /etc/init.d/iptables start
If you are using Debian / Ubuntu Linux open
# vi /etc/network/interfaces
Append the line to eth0 section:
Close and save the file. Reboot the system.