Restore iptables rules after a reboot on debian

12-12-2012 | Remy van Elst

Table of Contents

This small tutorial will help you set up iptables to survive a reboot. First you need to define the rules you want, then continue with this tutorial.

After the rules are defined and tested, execute the following command to save the rules to /etc/iptables.conf

iptables-save > /etc/iptables.conf

Now edit the /etc/network/interfaces file, and add the following right after the line which looks like iface eth0 inet static (eth0 and static might be different.):

  pre-up iptables-restore < /etc/iptables.conf

Now save the file, and after a reboot the IPtables rules will be in place.

Tags: debian  firewall  iptables  rules  tutorials