Iptables – Saving Firewall Rules Permanently on Ubuntu/Debian

there is a package named “iptables-persistent” that will automatically load firewall rules on startup, these rules must be saved in a File, /etc/iptables/rules.v4 for IPv4 and /etc/iptables/rules.v6 for IPv6.


apt-get install iptables-persistent

if the installation fails, check if there systemd had failures before installation of iptables-persistent, systemd error can cause the installation of iptables-persistent to fail


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

save rules, these will automatically be loaded at boot next time

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

restore/load previously saved rules

Leave a Reply

Your email address will not be published. Required fields are marked *