iptables – Packet Filtering

December 28, 2025
Download Now

iptables is the user-space utility for configuring Linux kernel firewall rules. It provides powerful packet filtering, network address translation, and connection tracking capabilities.

Key Features

  • Packet Filtering: Accept, drop, or reject packets
  • NAT: Source and destination NAT support
  • Stateful Inspection: Track connection states
  • Logging: Log matching packets
  • Chain System: Organized rule processing

Installation

iptables is included in most Linux distributions:

sudo apt install iptables iptables-persistent

Usage Examples

Common iptables rules:

# Allow established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Allow HTTP/HTTPS
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

# Drop all other incoming
iptables -A INPUT -j DROP

# Save rules
iptables-save > /etc/iptables/rules.v4

Benefits

iptables provides complete control over network traffic. Its kernel-level filtering ensures efficient processing while flexible rules handle complex security requirements.

Download iptables

Was this article helpful?