Persistent Iptables in Debian
I always forgot how to do simple stuff, configuring persistent iptables is one of them. In this recipe I will go through the process for Debian/Ubuntu.
What is iptables?
iptables is an utility that allows a system administrator to configure rules for the Linux kernel firewall; is an extremely flexible as firewall. For small site (like this) it will help you to keep away all the unwanted bots. If you have time you can check my post on nftables (the successor of iptables)
Installing iptables
In Debian it comes installed by default, if it’s not your case sudo apt install iptables
, for persistent we will use netfilter-persistent to install it you can execute:
|
|
Note: you can also install iptables-persistent, is not requiered, but you can use in your scripts to dump or read the rules from a file
Checking if is running
For this, as it install a service/daemon use:
|
|
Saving rules
At this point you can execute:
|
|
it will save all the rules you have, and:
Loading rules
|
|
will reload the rules you saved. You can see the current rules with sudo iptables -L -n
(-n to don’t delay the report with the naming resolution)
If you preffer to have a interface (very basic one) you can execute:
|
|
By default all the rules are saved in: /etc/iptables/rules.v4
and /etc/iptables/rules.v6
G