Oct 13th, 2009
Saving and Restoring iptables Rules
Saving and Restoring iptables Rules
The iptables package comes with two more tools that are very useful, specially if you are dealing with larger rule-sets.
These two tools are called iptables-save and iptables-restore
Firewall rules are only valid for the time the computer is on; so, if the system is rebooted, the rules are automatically flushed and reset.
To save the rules so that they are loaded later, use the following command:
The rules are stored in the file /etc/sysconfig/iptables and are applied whenever the service is started or restarted, including when the machine is rebooted.
The above command will in other words save the whole rule-set to a file called /etc/iptables-save with byte and packet counters still intact.
Example
Save current iptables firewall rules:
To restore iptables rules: