Sunday, May 05, 2024

youtube

   
Text Size

Articles

iptables save/restore on reboot

apt-get install iptables-persistent

These can be saved in a file with the command iptables-save for IPv4.

iptables-save > /etc/iptables/rules.v4

If you would also like to use IPv6 rules, these can be stored in a separate file.

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

These files can be loaded again with the command iptables-restore for IPv4.

iptables-restore < /etc/iptables/rules.v4

To do this, the rules must be saved in the file /etc/iptables/rules.v4 for IPv4 and /etc/iptables/rules.v6 for IPv6.