Use this when building or troubleshooting IPsec VPNs.
IPsec
IPsec secures IP traffic with authentication and encryption, commonly for site-to-site and remote-access VPNs. IKE negotiates keys and security associations, and ESP protects the packets.
1. IPsec architecture: IKE (keys), SAs, SPD (policies), ESP/AH.
2. Configure consistent proposals and selectors.
3. Strong algorithms.
4. Monitor SAs.
5. Plan MTU.
SPD policy → IKE → SA → ESP
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
show crypto ikev2 saVerification & 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 Checks Verify boundary
show crypto ikev2 sa
show crypto ipsec sa
swanctl --list-sas # strongSwan
Encaps and decaps counters should both increase.
Step 2 Common mistakes Narrow the fault
- Proposal mismatch (encryption, DH group, lifetime) between peers.
- NAT between peers without NAT-T (UDP 4500).
- Overlapping traffic selectors / proxy IDs.
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.
Subtopics
Go one level deeper into this subject.
IPsec architecture combines IKE for authentication and key exchange, ESP or AH for packet protection, security associations stored per direction, and transport or tunnel mode depending on what is protected.
Subtopic IKE Phase 1IKE Phase 1 (IKEv1) authenticates the peers with pre-shared keys or certificates and builds a secure IKE SA using Diffie-Hellman, which protects the Phase 2 negotiation.
Subtopic IKE Phase 2IKE Phase 2 (quick mode) negotiates the IPsec SAs that protect actual traffic — encryption, integrity, lifetimes, PFS and the traffic selectors or proxy IDs that must match on both ends.
Subtopic IKEv2IKEv2 is the modern IPsec key exchange: fewer messages, built-in NAT traversal, dead peer detection, EAP for remote access and MOBIKE for roaming clients.
Subtopic ESPESP (Encapsulating Security Payload, IP protocol 50) encrypts and authenticates IPsec packets.
Subtopic Authentication HeaderAH (Authentication Header, IP protocol 51) gives IPsec packets integrity and origin authentication but no encryption.
Subtopic Security AssociationsA security association (SA) is a one-way agreement on keys, algorithms and lifetime between IPsec peers, identified by an SPI.
Subtopic Encryption AlgorithmsIPsec encryption algorithms protect the data: use AES-GCM (128 or 256) or AES-CBC with a separate integrity algorithm.
Subtopic Integrity AlgorithmsIPsec integrity algorithms detect tampering, such as HMAC-SHA-256 or SHA-384.
Subtopic Diffie-Hellman GroupsDiffie-Hellman groups set the strength of IPsec key exchange.
Subtopic Perfect Forward SecrecyPerfect forward secrecy (PFS) in IPsec runs a fresh Diffie-Hellman exchange for each Phase 2 SA, so a compromised long-term key cannot decrypt past traffic.
Subtopic NAT TraversalNAT traversal (NAT-T) detects NAT between IPsec peers and wraps ESP in UDP port 4500, because NAT devices cannot translate raw ESP packets.
Subtopic IPsec TroubleshootingTroubleshoot IPsec by checking IKE and IPsec SA status, matching proposals (encryption, hash, DH group, lifetimes), pre-shared key or certificates, traffic selectors, UDP 500 and 4500 and ESP reachability, NAT and routing.
- IKE negotiates; ESP protects packets.
- Both ends must match proposals and traffic selectors.
- NAT requires NAT-T over UDP 4500.
ip xfrm state; ip xfrm policy— Linux IPsecshow crypto ipsec sa— Ciscoswanctl --list-sas— strongSwan
ReferenceWhy it matters1 section · depth on demand
What IPsec provides
IPsec protects IP packets with ESP (encryption and integrity) or AH (integrity only). IKE (UDP 500, and 4500 with NAT-T) authenticates peers and negotiates keys. It is used for site-to-site VPNs, remote access and host-to-host encryption.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
IPsec protects IP traffic with encryption, integrity and authentication at the network layer, transparently to applications. It is the standard for site-to-site VPNs and still widely used for remote access and cloud connectivity.
Components:
| Component | Role |
|---|---|
| IKE (v2) | Authenticates peers, negotiates algorithms, derives keys |
| ESP | Encrypts and authenticates packets |
| AH | Authentication only, rarely used |
| Security Associations | Agreed parameters per direction |
| Tunnel / transport mode | Whole packet vs payload protection |
The topics in this group cover IKE phases, algorithm choices (encryption, integrity, DH groups, PFS) and the trade-offs that decide whether a tunnel is both secure and interoperable.
Building blocks
| Part | Role |
|---|---|
| IKEv2 | Peer authentication and key exchange |
| ESP (protocol 50) | Encrypted, authenticated payload |
| SA | One-way agreement on keys and algorithms |
| Tunnel / transport mode | New outer IP header or original header kept |
| NAT-T | ESP inside UDP 4500 through NAT |
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. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301 · confidence 94%