18.4. Saving iptables Rules
iptablescommand are stored in memory. If the system is restarted before saving the
iptablesrule set, all rules are lost. For netfilter rules to persist through system reboot, they need to be saved. To do this, log in as root and type:
/sbin/service iptables save
iptablesinitscript, which runs the
/sbin/iptables-saveprogram and writes the current
/etc/sysconfig/iptables. The existing
/etc/sysconfig/iptablesfile is saved as
iptablesinit script reapplies the rules saved in
/etc/sysconfig/iptablesby using the
iptablesrule before committing it to the
/etc/sysconfig/iptablesfile, it is possible to copy
iptablesrules into this file from another system's version of this file. This provides a quick way to distribute sets of
iptablesrules to multiple machines.
/etc/sysconfig/iptablesfile to other machines, type
/sbin/service iptables restartfor the new rules to take effect.