iptables
Administration tool for IPv4 packet filtering and NAT firewall rules.
Synopsis
iptables [OPTION]... [CHAIN] [RULE]...
Examples
sudo iptables -L -n -v
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -s 10.0.0.0/8 -j DROP
sudo iptables -F
Common options
| Flag | Description |
|---|---|
| -A | Append rule to chain |
| -D | Delete rule from chain |
| -L | List rules |
| -F | Flush all rules |
| -P | Set default policy |
| -j | Target (ACCEPT, DROP, REJECT) |
About iptables
The `iptables` command administration tool for IPv4 packet filtering and NAT firewall rules. Networking commands handle connectivity testing, DNS resolution, data transfer, remote access, firewall rules, and traffic analysis.
Linux is the dominant server operating system, and strong networking skills are essential for web hosting, container orchestration, security auditing, and infrastructure management. The command accepts 6 commonly used flags shown above, though the full set of options is available in the man page (`man iptables`).
The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Network Commands
Other commands in the Network category