If you want your iptables rules automatically loaded every time your networking comes up on your Debian or Ubuntu server, you can follow these easy steps.
First, get your iptables rules set up the way you like them. Once you’ve verified that everything works, save the rules:
Next, open up
/etc/network/if-up.d/iptables in your favorite text editor and add the following:
Once you save it, make it executable:
Now, the rules will be restored each time your networking scripts start (or restart). If you need to save changes to your rules in the future, you can manually edit
/etc/firewall.conf or you can adjust your rules live and run:
Thanks to Ant for this handy tip.