Use it to understand what ESP protects, and when ESP is blocked by a firewall or NAT.
ESP
Encapsulating Security Payload (ESP, IP protocol 50) is the IPsec protocol that encrypts and authenticates the payload; it is used in almost all IPsec VPNs.
1. ESP (IP protocol 50) provides encryption and integrity.
2. NAT-T wraps ESP in UDP 4500.
3. Check encaps/decaps counters.
4. Firewalls must allow ESP or UDP 4500.
5. Use tunnel mode for site-to-site.
packet → ESP encrypt → peer decrypt
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification and what it shows Verify boundary
Generate a unique protected flow and compare outbound/inbound ESP packet counters, SPI/SA state and post-decrypt inner traffic on both peers. ESP packets on the wire show encapsulated transport only; they do not show successful decryption, inner routing or application response. Close with the same original workload.
Step 2 Observation → implication → next check Narrow the fault
Observation → implication → next check: IKE/child SA present with zero ESP counters points to traffic selectors or routing into the tunnel. Outbound ESP increasing without inbound response moves to peer path/firewall/NAT or remote policy. Inbound ESP with decrypt/replay errors moves to SA/key/replay state before application troubleshooting.
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.
- IKE SA and IPsec child SA are separate evidence boundaries
- Proxy identities/selectors must agree at both peers
- ESP commonly carries protected data; NAT traversal can encapsulate it in UDP 4500
- Encaps and decaps counters must be interpreted with generated interesting traffic and the return path.
show crypto ipsec sa— ESP SPI and counters
ReferenceWhy it matters1 section · depth on demand
How it works in operation
ESP carries protected IPsec payloads and provides confidentiality and/or integrity according to the negotiated child SA. Security policy/selectors decide which traffic enters ESP; sequence numbers, SPI and replay state belong to the SA, while routing and NAT still decide whether encapsulated packets reach the peer.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
ESP: the protocol that carries protected IPsec traffic
RFC 4303 defines the Encapsulating Security Payload. ESP is IP protocol 50 and provides confidentiality, data origin authentication, connectionless integrity, anti-replay and limited traffic-flow confidentiality. Integrity-only ESP must be supported; confidentiality-only ESP is optional.
ESP packet format (RFC 4303)
| Field | Size | Protected by |
|---|---|---|
| SPI | 32 bits | Integrity |
| Sequence Number | 32 bits | Integrity |
| Payload Data | Variable | Encryption and integrity |
| Padding | 0–255 bytes | Encryption and integrity |
| Pad Length | 8 bits | Encryption and integrity |
| Next Header | 8 bits | Encryption and integrity |
| ICV (Integrity Check Value) | Variable | — |
Modes (RFC 4303)
| Mode | Layout | Use |
|---|---|---|
| Transport | IP header / ESP / original payload | Host-to-host, or GRE over IPsec between the tunnel endpoints |
| Tunnel | New IP header / ESP / original IP packet | Gateway-to-gateway VPNs and VTIs |
host$ sudo tcpdump -n -i eth0 'esp or udp port 4500'
IP 198.51.100.2 > 203.0.113.2: ESP(spi=0x4d02b7e3,seq=0x1cb8f2), length 152
IP 203.0.113.2 > 198.51.100.2: ESP(spi=0x8c1f22a1,seq=0x1b6a09), length 104
IP 192.0.2.77.4500 > 203.0.113.2.4500: UDP-encap: ESP(spi=0x2a91c6d0,seq=0x12), length 136
The first two lines are native ESP. The third is ESP in UDP 4500, used when NAT sits between the peers.
Algorithms (RFC 4303)
ESP can use separate encryption and integrity algorithms, or a combined-mode algorithm such as AES-GCM that provides both in one operation. With combined mode the integrity check is part of the algorithm's output.
Anti-replay (RFC 4303)
The receiver uses a sliding window to drop duplicates and packets older than the window. The minimum window is 32 and the recommended default 64. Anti-replay needs integrity to be enabled.
ESP versus AH
AH (protocol 51) authenticates the packet, including parts of the outer IP header, but doesn't encrypt and can't pass through NAT. ESP is used for practically all IPsec VPNs today.
Documented example, not captured output.
Quick reference
ESP is the IPsec protocol that actually carries protected traffic. It encrypts the payload and adds integrity and replay protection. Because ESP is its own IP protocol rather than TCP or UDP, firewalls and NAT devices must handle it explicitly; when NAT is detected, IPsec wraps ESP inside UDP 4500 instead.
ESP (IP protocol 50) provides confidentiality, integrity and anti-replay for the payload. Tunnel mode encrypts the whole original packet behind a new IP header; transport mode (used under GRE) protects only the payload.
crypto ipsec transform-set TS esp-gcm 256
mode tunnel
show crypto ipsec sa | include pkts|spi|current_peer
AH (protocol 51) authenticates without encryption and breaks with NAT — it is rarely used. Firewalls between peers must allow UDP 500/4500 and ESP (or only UDP 4500 when NAT-T is in use).
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 Virtualization & Overlays → IPsec → ESP. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301.html · confidence 94%