Linux · System Tools
iptables
iptables is a command-line firewall tool for managing network traffic on Linux systems.
- License
- GPL-2.0
- Latest version
- 1.8.13
What is iptables?
iptables has been the standard Linux firewall since the 2.4 kernel, providing low-level control over network packet filtering. It interacts with the netfilter framework in the kernel, allowing precise rules for IPv4 traffic. Despite its age, it's stable, well-documented, and deeply integrated into most distributions.
It's best suited for system administrators, server operators, or advanced users who need fine-grained control over network access. Desktop users rarely interact with it directly, as higher-level tools often manage it behind the scenes. If you're comfortable with the command line and need to define custom firewall behavior, iptables is a solid choice.
Compared to Windows Defender Firewall, iptables feels more technical and less visual. There's no GUI by default, and rules are applied immediately without confirmation dialogs. While Windows tools guide users with wizards and toggles, iptables requires understanding of chains, targets, and rule order—offering more power but a steeper learning curve.
Best for: Users who need precise, scriptable control over IPv4 firewall rules on Linux.
Key features of iptables
- Packet filtering based on IP, port, protocol, and interface
- Support for custom chains and rule ordering
- Network Address Translation (NAT) for routing and masquerading
- Stateful inspection (e.g., RELATED, ESTABLISHED)
- Logging of matched packets
- Integration with scripts and automation tools
- Rule persistence via distribution-specific save/restore methods
Pros
- Highly flexible and precise control over traffic
- Available on nearly every Linux system by default
- Scriptable and suitable for automation
- Well-documented with extensive community examples
- No performance overhead—runs in kernel space
Cons
- No built-in GUI; command-line only
- Syntax is complex and error-prone for beginners
- IPv6 requires a separate tool (ip6tables)
- Rules are not persistent by default—must be saved manually
Windows programs iptables replaces
How to install iptables on Linux
sudo apt install iptablessudo apt install iptablessudo dnf install iptablessudo pacman -S iptablessudo zypper install iptablesTips for Windows users
Windows Defender Firewall uses a GUI with predefined rules and profiles (domain, private, public). iptables works differently: rules are ordered in chains and applied via command line. You’ll need to learn the syntax for adding, listing, and deleting rules. Use 'iptables-save' and 'iptables-restore' to manage rule persistence. Tools like ufw or firewalld can simplify the process if you're not ready for raw iptables.
iptables: frequently asked questions
Is iptables still used, or has it been replaced?
Yes, iptables is still widely used. While nftables is its intended successor, iptables remains active and supported through a compatibility layer in most distributions.
How do I make iptables rules permanent?
Rules are lost on reboot unless saved. On Debian/Ubuntu, use 'iptables-save > /etc/iptables/rules.v4'. On RHEL/Fedora, use 'service iptables save' if the service is enabled.
Can iptables block applications like Windows Firewall?
No, iptables filters by port, IP, and protocol—not by process name. To block apps, you need to know which ports they use or use additional tools like 'nftables' with cgroup support.
Does iptables support IPv6?
Not directly. Use 'ip6tables' for IPv6 rules. It works the same way but requires separate rule sets and management.
Updated