Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

iptables Legacy Linux Firewall Reference Cheat Sheet

iptables Legacy Linux Firewall Reference Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-21
Next Topic: journalctl and systemd Logging Cheat Sheet

iptables is the long-standing user-space tool for configuring the Linux kernel's netfilter packet-filtering framework, giving administrators granular control over how network packets are accepted, dropped, modified, or forwarded. Despite being superseded by nftables in most modern distributions, iptables remains heavily deployed on production servers running RHEL 7/CentOS 7/Ubuntu 18.04 and in countless scripts, containers, and tools that expect its interface. The key mental model: iptables doesn't contain the firewall logic itself β€” it programs five hooks deep in the kernel networking stack, organized into tables (by purpose) and chains (by hook point), so understanding that layering is essential before writing a single rule.

What This Cheat Sheet Covers

This topic spans 22 focused tables and 147 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Tables β€” Purpose and Available ChainsTable 2: Built-in Chains and Their Netfilter HooksTable 3: Packet Traversal Paths and Table Processing OrderTable 4: Rule Syntax and Core Command OptionsTable 5: Match Extensions (Common Criteria)Table 6: Targets β€” Actions Taken on Matched PacketsTable 7: Connection Tracking StatesTable 8: NAT Targets β€” Address and Port TranslationTable 9: Port Forwarding and Source NAT PatternsTable 10: Rate Limiting β€” limit, hashlimit, recent, connlimitTable 11: Persistence β€” Saving and Restoring RulesTable 12: Custom Chains and Organizational PatternsTable 13: Mangle Table β€” Packet Header AlterationTable 14: IPv6 with ip6tablesTable 15: Bridge and ARP Filtering β€” ebtables and arptablesTable 16: iptables-legacy vs iptables-nft Compatibility ShimTable 17: Migration to nftables β€” iptables-translateTable 18: Docker and iptables InteractionTable 19: fail2ban and iptables InteractionTable 20: Troubleshooting β€” Listing, Counters, and DebuggingTable 21: Common Security Patterns β€” Default-Deny, SSH, Web ServerTable 22: Performance Considerations vs nftables

Table 1: Tables β€” Purpose and Available Chains

Each iptables table serves a distinct purpose. The right table must be selected before writing rules, because targets and chains available to each table differ β€” placing a NAT rule in the filter table simply won't work.

TableExampleDescription
filter
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
β€’ Default table (no -t needed)
β€’ decides whether to allow or deny packets
β€’ Contains INPUT, FORWARD, OUTPUT chains
nat
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
β€’ Network Address Translation
β€’ consulted only for the first packet of a new connection
β€’ Contains PREROUTING, INPUT, OUTPUT, POSTROUTING chains
mangle
iptables -t mangle -A PREROUTING -i eth0 -j TTL --ttl-set 64
Specialized packet header alteration (TTL, TOS, DSCP, MARK). Contains all five chains.

More in Operating Systems and CLI

  • GCP CLI Cheat Sheet
  • journalctl and systemd Logging Cheat Sheet
  • AWS CLI Cheat Sheet
  • jq Command-Line JSON Processor Cheat Sheet
  • macOS Usage Cheat Sheet
  • systemd and Linux Service Management Cheat Sheet
View all 48 topics in Operating Systems and CLI