Rules disappear after restarting iptables


2017-06-05 05:07:59 UTC


2017-07-04 08:49:38 UTC


Was this article helpful?

Have more questions?

Submit a request

Rules disappear after restarting iptables

Applicable to:

  • Plesk for Linux/Unix
  • Plesk Sitebuilder for Linux/Unix
  • Plesk Expand
  • Virtuozzo containers for Linux
  • Virtuozzo hypervisor
  • Operations Automation
  • Business Automation
  • Odin Business Automation Standard


I have stopped and started iptables with these commands:

# /etc/init.d/iptables stop
# /etc/init.d/iptables start

Now I see that some rules have disappeared. What could be the reason?


If rules were added using /sbin/iptables 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 during an iptables restart, you need to save them before the restart.

Method 1:
# iptables-save > iptables_save.txt

If using this method, you will need to restore the rules after the restart:
# iptables-restore <iptables_save.txt

Method 2:
# /etc/init.d/iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]

The above command saves the rules to the file system, and an iptables restart will not affect them.
This method is preferable if you want to leave the server intact.
Have more questions? Submit a request
Please sign in to leave a comment.