Iptables – save running configuration and dropping configuration

Table of Contents

CentOS #

This OS provides firewalld as default to administrate system firewall. For switch back to classic iptabales, you need to remove firewalld first:

$ yum remove firewalld
$ yum install iptables iptables-services

Now save your current iptables rules:

$ service iptables save

Please remember to enable iptables on autostart:

$ systemctl enable iptables

You can review your saved iptables configuration in /etc/sysconfig/iptables

To stop iptables, just run:

$ service iptables stop

Debian/Ubuntu #

Please install iptables-persistent package:

$ apt-get install iptables-persistent

The package installer will ask you to save current settings, please feel free to save them.
Rules are stored in /etc/iptables/rules.v4 for IPv4 and /etc/iptables/rules.v6 for IPv6.

To save your rules from command line, please type:

$ service netfilter-persistent save

To reload your iptables rules, please type:

$ service netfilter-persistent reload

If you want to stop iptables, please type:

$ service netfilter-persistent stop