Q&A-1Compare IPsec transport and tunnel modes.
Answer
The 90-second answer
Assume IPv4, ESP rather than AH, and that "endpoints" means the devices terminating IPsec. The difference is one thing: what the outer IP header addresses. Transport mode keeps the original IP header as the outer header and inserts ESP between it and the transport header, so the packet on the wire is addressed host-to-host and only the payload is protected. Tunnel mode wraps the whole original packet, header included, inside a new packet addressed gateway-to-gateway, so the inner addresses are invisible on the wire. Pick transport when the two hosts talking are the two IPsec endpoints; pick tunnel when a gateway, a remote-access client, or overlapping address space is involved.
Mechanism
ESP in transport mode: [IP hdr][ESP hdr][TCP/UDP + data][ESP trailer][ICV]. The IP header's protocol field becomes 50, and the header stays in the clear (mutable fields like TTL and checksum can't be protected anyway). ESP in tunnel mode: [new IP hdr][ESP hdr][original IP hdr + payload][ESP trailer][ICV]. The original header is now encrypted payload.
AH differs: it authenticates the IP header too, so AH transport mode breaks under NAT. Any address rewrite invalidates the ICV and the packet is dropped. ESP doesn't cover the outer header, which is why ESP survives NAT once wrapped in UDP 4500 (NAT-T, RFC 3948; IKE itself uses UDP 500).
Comparison
| Transport | Tunnel | |
|---|---|---|
| outer src/dst | the two hosts | the two gateways |
| inner header | visible, routable | encrypted |
| ESP overhead | ~22 B (8 hdr + 2 trailer + 12 ICV, SHA-1) + padding to 16 B | same + 20 B new IPv4 header |
| NAT | ESP needs NAT-T; AH impossible | ESP needs NAT-T |
| typical use | host-to-host, GRE-over-IPsec | site-to-site, remote access |
Worked trace
Host 10.0.0.5 → 10.0.1.9, gateways 203.0.113.1 and 198.51.100.1.
Transport: [IP 10.0.0.5→10.0.1.9 proto=50][ESP][TCP dport=443]. A router between them sees 10.0.0.5 → 10.0.1.9 and can route, QoS, and ACL on those addresses.
Tunnel: [IP 203.0.113.1→198.51.100.1 proto=50][ESP][IP 10.0.0.5→10.0.1.9 proto=6][TCP dport=443]. The router sees only the gateway addresses; 10.0.0.5 is encrypted.
Trade-offs and when not to use
Transport mode keeps the original addresses visible, so intermediate routers can route and classify on them, but it only works when the communicating hosts are themselves the IPsec endpoints, which doesn't scale to a site-to-site mesh. Tunnel mode scales to gateways and hides internal addressing (useful when both sites use 10.0.0.0/8), at the cost of ~20 extra bytes and no visibility for intermediate policy. Don't use transport mode for a gateway-to-gateway VPN; don't use tunnel mode when you need per-flow routing on the real addresses.
Failure modes
- MTU black hole: tunnel mode adds ~50-73 B, so a 1500 B inner packet exceeds the path MTU. If ICMP "frag needed" is filtered, small packets pass and large transfers hang. Detect with
ping -M do -s 1472and step down; fix with MSS clamping or a lower tunnel MTU (~1400). - NAT + AH: ICV mismatch, silent drops. Detect by comparing counters on both ends.
- Overlapping subnets in tunnel mode: two sites both on 192.168.1.0/24 collide; the SPD can't distinguish them. Detect at policy-install time.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.