iptables

Configure the Linux kernel firewall — manage network packet filtering rules.

high risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
Safer / dry-run alternatives
iptables-save > /root/iptables.backupBack up the current rules.
echo 'iptables-restore < /root/iptables.backup' | at now + 5 minutesAuto-rollback if you lock yourself out (cancel with atrm once verified).
What it does

iptables manages netfilter rules through chains. INPUT/OUTPUT/FORWARD handle incoming, outgoing, and routed traffic. Rules are evaluated top-to-bottom; first match wins. Save rules with iptables-save before making changes.

Common flags
FlagMeaning
-A --appendAppend a rule to a chain
-I --insertInsert a rule at the top (highest priority)
-D --deleteDelete a specific rule
-L --listList all rules in a chain
-n --numericShow numeric IPs without hostname resolution
-F --flushDelete all rules from a chain
Examples
iptables -L -nvList all firewall rules with packet/byte counts numerically · explain & risk-check →
iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j ACCEPTAllow SSH only from private 10.x.x.x range · explain & risk-check →
iptables-save > /etc/iptables/rules.v4Save current rules to persist across reboots · explain & risk-check →
Pro tip

Before adding restrictive rules on a remote server: `echo 'iptables -F' | at now + 5 minutes` — schedules a flush so you can't permanently lock yourself out.

Related
ufw nftables firewalld ss
Open the full explainer →More in Networking

Reference text is hand-written and may be incomplete — check man iptables for your version. Test destructive commands on a non-production system first.