How to make iptables rules persistent after reboot on Linux


Iptables rules are by default not persistent after reboot. The objective is to make iptables rules persistent after reboot.


Privileged remote or physical access to your Ubuntu or Debian Linux system is required to complete this task.




iptables-persistent installation

In order to make your iptables rules persistent after reboot install iptables-persistent package using apt-get tool:

# apt-get install iptables-persistent

Any currently erected iptables rulles will be saved to corresponding IPv4 and IPv6



Updating iptables rules

To update persistent iptables with new rules simply use iptables command to include new rules into your system. To make changes permanent after reboot run iptables-save command:

# iptables-save > /etc/iptables/rules.v4
# ip6tables-save > /etc/iptables/rules.v6

Remove persistent iptables rules

To remove persistent iptables rules simply open a relevant /etc/iptables/rules.v* file and delete lines containing all unwanted rules.

Comments and Discussions
Linux Forum