In this article you will learn how to uninstall default nftables framework, install iptables Debian 11 (Bullseye) and basic rules initial configuration.
Uninstall nftables and its Dependencies
IPtables is being replaced by nftables starting with Debian 10 Buster. Debian 11 comes with nftables framework.
To install iptables first we need uninstall nftables and its dependencies.
SSH into your server and run the next commands:
# apt-get remove --auto-remove nftables # apt-get purge nftables
Install IPtables in Debian 11
To install iptables execute following commands:
# apt-get update # apt-get install iptables
Debian IPtables Status Check
Now we can check the iptables status and list rules. For list all the rules we will use option -L.
Run command:
# iptables -L -v
You will see the output:
As you see on the screenshot just installed iptables firewall and it works. But all chains (INPUT, FORWARD, OUTPUT) are set to ACCEPT, and we have no security rules configured.
Clear Iptables Rules
То clear iptables rules (open all ports) use the following command sequence:
# iptables -P INPUT ACCEPT # iptables -F # iptables -X
Debian Iptables Persistent
To make your iptables rules persistent install iptables-persistent package:
# apt-get install iptables-persistent
Now Iptables Configuration files rules.v4 and rules.v6 stored in /etc/iptables
Debian IPtables Save
To update iptables with new rules use IPtables Save command:
# iptables-save > /etc/iptables/rules.v4
for IPV6:
# ip6tables-save > /etc/iptables/rules.v6
Iptables Restore
To restore iptables configuration form iptables configuration file.
# iptables-restore < /etc/iptables/rules.v4
Ref: