Interview Prep/Networking/NAT, Firewalls & VPN

What does the iptables chain order look like for a packet?

IntermediateConceptNAT, Firewalls & VPN
Answer

Incoming packets hit PREROUTING (raw, mangle, nat), then a routing decision: local delivery goes through INPUT, forwarded packets go through FORWARD, then POSTROUTING. Locally generated packets go OUTPUT then POSTROUTING. Within each hook, tables are evaluated in a fixed order (raw, conntrack, mangle, nat, filter).

DNAT happens in PREROUTING before routing, SNAT/MASQUERADE in POSTROUTING after. nftables replaces iptables in modern distros with the same hook model.

All Networking questions Roadmap: Networking for DevOps

More on NAT, Firewalls & VPN