Easy Debian 9 Server Firewall

If you read our previous article Easy Debian Server Firewall, then you may have noted that on Debian Stretch the described method no longer works. This is due to systemd. In the article below we will walk through creating a persistent IPTables based firewall on Debian Stretch. First we need to install some required software packages. As seen in the command below, install iptables-persistent. Next we will make netfilter-persistent run at boot. This is the most important step as it will ensure your rules are reloaded at boot time.

Once the packages above are installed, you will have a new directory at /etc/iptables/. This directory holds the IPTables filter rules that will be reloaded at boot time. These files are named rules.v4 and rules.v6 respectively. IPV4 rules are loaded into rules.v4 and IPV6 rules are loaded into rules.v6. For the purpose of this article we will focus on IPV4 rules. Next we will want to copy the rules below into our rules.v4 file. Of course the rules will need to be modified to fit your environment.

Lastly, in order for our new rules to take affect, we simply need to restart the netfilter-persistent service as seen below. That’s it, you now have a fully functional IPTables based firewall.

Did you find this article useful? Why not share it with your friends?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.