- Plesk for Linux
iptables service was restarted. After that, some rules have disappeared. What could be the reason?
If rules were added using
utility, they were added to a chain in the memory and were not committed to the hard disk. Upon restart, those rules were flushed from the memory and not restored.
In order to avoid losing rules after iptables restart, it is required to save the rules.
on CentOS/RHEL-based distributions
Connect to the server via SSH and do the following:
# service iptables-save > iptables_save.txt
If using this method, you will need to restore the rules after the restart:
# service iptables-restore < iptables_save.txt
# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
The above command saves the rules to the file system, and iptables restart will not affect them.
on Debian/Ubuntu-based distributions
# iptables-save > /etc/iptables/rules.v4
# iptables-restore < /etc/iptables/rules.v4
Install the iptables-persistent package:
# apt-get install iptables-persistent