← Module 06 · Security & Encryption

IPsec Fundamentals (AH vs ESP)

IPsec (IP Security) protects traffic at the network layer itself, transparent to everything running above it, using two very differently capable protocols.

Two protocols, two different jobs

Think of a shipping container. A tamper-evident seal on the outside proves nobody opened it in transit and confirms who sent it, but anyone can still see straight through the container's mesh sides at what's inside if they look. A fully sealed, opaque, locked container does both: nobody can see the contents without the key, and it can carry that same tamper-proof seal too. IPsec's two protocols map directly onto that difference.

AHESP
Confidentiality (encryption)NoYes
Integrity / authenticationYesYes, typically
Protects the outer IP headerYes, its immutable fieldsNo
Works through NATNo, without extra helpYes, with NAT-T (NAT Traversal)
IP protocol number5150

Transport mode vs tunnel mode

Transport mode protects just the original payload, leaving the original IP header alone; it's a host-to-host arrangement. Tunnel mode wraps the entire original packet, header and all, inside a brand new outer IP header, which is what makes site-to-site VPNs possible: the two gateways' IP addresses are all that's visible from the outside, and every internal host behind either gateway is completely unaware the tunnel even exists.

New IP Header (tunnel endpoints) ESP Header Original IP Header Original Payload ESP Trailer ESP Authentication (optional)
Everything from the original IP header through the ESP trailer is encrypted; only the new outer IP header stays in plaintext, since routers along the path still need to read it to forward the packet.
WHY ESP DOMINATES IN PRACTICE

AH authenticates fields in the IP header that NAT (Network Address Translation) rewrites in transit, which breaks AH's integrity check the moment a NAT device touches the packet. Combined with offering no confidentiality at all, that's why almost every real-world IPsec deployment today uses ESP, either alone or with its own authentication enabled, and AH is mostly a historical footnote.