By default Ubuntu / Debian do NOT save any IPTables settings when shutting down. I think the thought behind this is that if you screw up a config, then a restart will save you.
In some instances, such as a traffic routing VPN or you have specific firewall needs, custom IPTables rules are needed to be loaded on boot.
To see what your current IPTables rules are, use:
To save the IPTables to a file, such as ‘firewall.conf’ use:
To then reload and restore the ruleset upon boot (or actually when the network goes up, which makes a lot more sense) we need to make a script in /etc/network/if-up.d/ that loads the presaved file. For example, I’ve called mine /etc/network/if-up.d/iptablesrestore and it looks like:
iptables-restore < /etc/firewall.conf
Don’t forget to chmod +x /etc/network/if-up.d/iptablesrestore to make it executable.