Network

iptables

Administration tool for IPv4 packet filtering and NAT firewall rules.

Synopsis

syntax
iptables [OPTION]... [CHAIN] [RULE]...

Examples

List all rules with verbose numeric output
sudo iptables -L -n -v
Allow SSH
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Block a subnet
sudo iptables -A INPUT -s 10.0.0.0/8 -j DROP
Flush all firewall rules
sudo iptables -F

Common options

FlagDescription
-AAppend rule to chain
-DDelete rule from chain
-LList rules
-FFlush all rules
-PSet default policy
-jTarget (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

Related tools