How To Save/Restore Iptables Rules

by lifeLinux on May 18, 2011

Save Iptables rules

Rules created with the iptables command are stored in memory. If the system is restarted before saving the iptables rule set, all rules are lost. To save netfilter rules, type the following command as root:

# /etc/init.d/iptables save 


If you are using IPv6, enter:

# /etc/init.d/ip6tables save 

The above commands will write the current iptables configuration to /etc/sysconfig/iptables. The next time the system boots, the iptables init script reapplies the rules saved in /etc/sysconfig/iptables. You can also save the iptables rules to a separate file for distribution, backup or other purposes. Type the following command as root

# iptables-save > /root/iptables.rules

If you are using IPv6, enter:

# ip6tables-save  > /root/iptables.rules

Restore Iptables rules

To restore it use the command iptables-restore, type the following command as root:

# iptables-restore < /root/iptables.rules

If you are using IPv6, enter:

# ip6tables-restore < /root/iptables.rules

Related Posts:

Previous post:

Next post: