I’m pretty sure canonical had its reasons to make ubuntu iptables rules non-persistent by default. I can imagine situation when playing with rules could result in forcing yourself out of ssh connection. But, this non-persistence is annoying when you have rules set up the way you want it…

Fortunately it is very easy to “fix” this.

We will use iptables-save and iptables-restore.

Now edit /etc/rc.local (this file runs on boot, we will use it to restore iptables rules on start)
Before exit 0 add:

And that’s it.

p.s. Every time you add new rules, don’t forget to save them:

Leave a Reply

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