Skip to main content
Kill -9 Club
Sign in

iptables

NetworkPackage: iptablesHandle with care

Linux's historical rule-based firewall; on recent Ubuntu, a compatibility layer over nftables. Rules live in memory: what you add is gone at reboot unless something saves it.

A mistake with this command can destroy data or lock you out

  • A DROP rule on port 22, or a default DROP policy set before the rule allowing SSH, cuts your own session. Test with a sleep 120 && iptables -F started beforehand, or from the console.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

iptables -L
Lists the rules. On Ubuntu 24.04 the command is the nft front end: it shows the same ruleset nft does, in an older grammar and without what nft can additionally express.
iptables -n
Performs no name resolution: addresses and ports stay numeric. Without it, the listing waits on DNS rule by rule.
iptables -v
Verbose listing, with each rule's packet and byte counters. They are what says which rule is actually seeing traffic.
iptables --version
Prints the version and, in parentheses, the backend in use: nf_tables or legacy. The one quick way to know which of the two you are querying.

Lessons that teach it