Automatically loading iptables rules on Debian/Ubuntu

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 save your firewall rules
iptables-save > /etc/iptables/iptables.rules

// Edit startup file at 
nano /etc/network/if-up.d/iptables

// Fill in the correct iptables path
iptables-restore < /etc/iptables/iptables.rules

Now, the rules will be restored each time your networking scripts start (or restart).