Save iptables settings to be persistent on reboot
By default, any modification to the iptables rules are not automatically automatically saved, this is how to change that.
(All commands in here should run as root: Running everything as root without sudo on every line)
To save iptables settings to a file, you use the ‘iptables-save’ command, and it can be used like this:
iptables-save > /etc/iptables.rules
To restore settings from a previously saved file, use this:
iptables-restore < /etc/iptables.rules
For settings to be reloaded automatically, you need to execute the above command on every boot, the right way to do it, is by appending a line like this to each interface configuration in ‘/etc/network/interfaces’ file, but, this is not an option on ubuntu desktop or linux mint, since they have the network manager, in that case this should work:
and append this line to the end:
@reboot root iptables-restore < /etc/iptables.rules
Reboot to test the new configuration.