Course contentsShow
← Security
Lesson 436 of 3,05210. Network Security - Firewalls and SegmentationFree lesson

iptables Architecture and Tables

Understanding iptables' filter, nat, mangle, and raw tables and their roles in packet processing pipeline.

iptables Architecture and Tables

You'll learn: How iptables organizes packet-filtering rules into specialized tables that work together in a processing pipeline.

The Core Idea

Think of iptables as a mail-sorting facility with four specialized departments, each handling different aspects of package processing. When a network packet arrives, it doesn't just face one yes/no checkpoint—it travels through multiple tables, each with its own job in the pipeline.

The Four Tables

1. filter (the security guard)
This is your primary firewall table. It decides: "Should I ACCEPT, DROP, or REJECT this packet?" Most basic firewall rules live here. If you're blocking SSH or allowing HTTP, you're working in the filter table.

2. nat (the address translator)
Handles Network Address Translation—rewriting source or destination IP addresses. Used for port forwarding, masquerading outbound traffic, or redirecting connections. Think of it as the table that changes "where" packets are going or coming from.

3. mangle (the packet modifier)
Alters packet headers—changing TTL values, marking packets for Quality of Service (QoS), or modifying TCP options. This is for advanced packet manipulation beyond simple allow/deny decisions.

4. raw (the early interceptor)
Processes packets before connection tracking begins. Used primarily to mark packets that should bypass connection tracking for performance reasons. This is the first table packets encounter.

The Pipeline Order

Packets flow through tables in a specific order: raw → mangle → nat → filter. Each table examines the packet according to its specialty, then passes it along or makes a terminal decision (DROP/ACCEPT).

Key Takeaway: iptables uses four specialized tables (filter, nat, mangle, raw) that each handle different packet processing tasks, working together in a defined order to make comprehensive firewall decisions.