Advanced
Package: iptables
iptables
Directly configure Linux kernel packet-filtering rules.
Syntax
iptables [options]
Description
iptables manages the traditional netfilter rule chains directly. It is lower-level than ufw or firewalld (which both generate iptables/nftables rules under the hood) and gives complete control at the cost of a steeper learning curve.
Examples
sudo iptables -L -v -n
List current rules with packet/byte counters
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Append a rule allowing incoming SSH
sudo iptables -P INPUT DROP
Set the default policy for incoming traffic to drop
Many modern distributions are migrating the underlying engine to nftables, with iptables kept as a compatible command syntax.