Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

Restore iptables rules after a reboot on debian

Published: 12-12-2012 | Author: Remy van Elst | Text only version of this article


❗ This post is over twelve years old. It may no longer be up to date. Opinions may have changed.

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.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

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