Use this when ESP protects IPsec traffic.
ESP · IPsec
ESP (Encapsulating Security Payload, IP protocol 50) encrypts and authenticates IPsec packets. In tunnel mode it protects the whole original packet, and over NAT it is carried in UDP 4500.
1. ESP provides confidentiality, integrity and anti-replay.
2. AES-GCM (AEAD) recommended.
3. Sequence numbers / ESN for anti-replay.
4. Check both counters.
5. Replay errors = reordering or duplicate SAs.
payload → ESP encrypt/authenticate → peer decrypts
Context & applicabilityCommon mistakes · platform/version boundaries
- ESP (IP protocol 50) blocked by a firewall while UDP 500 is allowed — the tunnel comes up but no data passes.
- Using ESP without integrity (encryption-only) — always use AEAD or an HMAC.
- Fragmentation after encryption causing slow or broken large transfers.
- Anti-replay window too small for networks with packet reordering (QoS).
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- ESP is IP protocol 50.
- Tunnel mode protects the whole original packet.
- Behind NAT, ESP is carried in UDP 4500.
ip xfrm state | grep -E 'aead|enc|auth'— algorithmsshow crypto ipsec sa | include encaps|decaps— counterstcpdump -ni <if> esp or udp port 4500— packets
ReferenceWhy it matters1 section · depth on demand
Tunnel vs transport mode
| Tunnel mode | Transport mode | |
|---|---|---|
| Protects | Whole original IP packet | Payload only |
| New IP header | Yes (gateway addresses) | No (original addresses visible) |
| Typical use | Site-to-site VPN, VTI | Host-to-host, GRE over IPsec |
ESP adds a header (SPI, sequence number), padding and an integrity check value. show crypto ipsec sa shows encaps/decaps counters per SA; counters increasing on only one side point to routing or a filter on the return path.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
ESP in the IPsec architecture provides confidentiality, data origin authentication, integrity and anti-replay for packets. With AEAD algorithms such as AES-GCM, one algorithm provides both encryption and integrity.
ESP packet structure (tunnel mode):
| Part | Contents |
|---|---|
| New IP header | Gateway addresses |
| ESP header | SPI, sequence number |
| IV | Per-packet value |
| Encrypted payload | Original IP packet + padding + next header |
| ICV | Integrity check value |
Anti-replay drops packets with sequence numbers outside the window; QoS reordering after encryption can cause replay drops, which are visible as replay errors in SA statistics.
ESP packet layout
[ New IP ][ ESP header: SPI, Seq ][ IV ][ Inner IP + payload (encrypted) ][ Padding, Next header ][ ICV ]
Overhead is roughly 50–60 bytes in tunnel mode with AES-GCM, more with CBC + HMAC. Lower the tunnel MTU or TCP MSS (e.g. ip tcp adjust-mss 1360) to avoid fragmentation.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in IPsec → ESP. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301 · confidence 94%