Backup and recovery of iptables rules in Ubuntu requires that iptables rules be automatically loaded when the Ubuntu server is restarted. The method is as follows: first, save iptables rules to a file # sudo iptables-save>/etc/iptables. up. rules then modifies the/etc/network/interfaces script to automatically apply these rules (the last line is added) sudo echo "pre-up iptables-restore </etc/iptables. up. rules ">/etc/network/interfaces you can also prepare a set of rules to automatically apply it
Sudo echo "pre-up iptables-restore </etc/iptables. up. rules ">/etc/network/interfacessudo echo" post-down iptables-restore </etc/iptables. down. rules ">/etc/network/interfaces www.2cto.com the above method has been tested on Ubuntu 12.04 and takes effect. The test result is invalid for the following method. Searching for the cause... if a friend knows the cause,
I hope I can leave a message. Thank you. My testing environment is Ubuntu 12.04. Before restarting, back up the current iptables rule and import the rule to iptables when the server is started. The operation is as follows: Back up the iptables rule and save the rule file to the current user directory. Iptables-save> ~ /Iptables. bak restore iptables rules: iptables-restore <~ /Iptables. bak writes the restore rule to the self-starting script. The script file is/etc/rc. localecho "iptables-restore <~ /Iptables. bak ">/etc/rc. local