Use this to understand IPsec components and modes.
IPsec Architecture
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.
1. Components: SPD (which traffic), SAD (keys), IKE daemon, ESP/AH processing.
2. Policy decides protect/bypass/discard.
3. Kernel does ESP; userspace does IKE.
4. Route-based vs policy-based.
5. Know your model.
packet → SPD lookup → SA → ESP
Context & applicabilityCommon mistakes · platform/version boundaries
- Mismatched proxy IDs / traffic selectors between peers.
- NAT applied to traffic that should enter the tunnel (missing NAT exemption).
- Routing sends traffic out the internet interface instead of the tunnel (route-based VPNs need a route via the tunnel interface).
- Lifetimes that differ widely between peers, causing rekey problems on some platforms.
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.
- IPsec combines IKE, ESP/AH and security associations.
- Tunnel mode suits gateways; transport mode suits hosts.
- Policies decide which traffic is protected.
ip xfrm policy— SPD (Linux)ip xfrm state— SADswanctl --list-conns— configuration
ReferenceWhy it matters1 section · depth on demand
Packet journey
1. Traffic matches the tunnel (route to a VTI or a crypto ACL).
2. If no SA exists, IKE negotiates one (IKE SA, then Child/IPsec SA).
3. The packet is encrypted with ESP using the SA's keys and sent to the peer (UDP 4500 if NAT is detected).
4. The peer checks integrity and anti-replay, decrypts and forwards.
Troubleshoot in the same order: routing/selector → IKE → IPsec SA → counters on both sides → return routing.
ReferenceImportant terms & boundaries2 sections · depth on demand
Components
| Component | Role |
|---|---|
| IKE (UDP 500/4500) | Authenticates peers and negotiates keys |
| SA (Security Association) | One-way agreement: SPI, keys, algorithms, lifetime |
| SPD | Policy: which traffic must be protected |
| SAD | Database of active SAs |
| ESP / AH | Protect the packets |
Each tunnel has a pair of IPsec SAs (one per direction) under one IKE SA.
In depth
IPsec architecture (RFC 4301) defines how IP packets are protected: a Security Policy Database (SPD) decides which traffic must be protected, bypassed or discarded; a Security Association Database (SAD) holds the negotiated SAs; IKE populates the SAs; and ESP/AH process the packets.
| Component | Role |
|---|---|
| SPD | Policy: protect / bypass / discard per traffic selector |
| SAD | Active SAs with keys, algorithms, sequence numbers |
| PAD | Peer authorisation (which identities may negotiate) |
| IKEv2 | Key management |
| ESP/AH | Data protection |
Route-based VPNs (VTI) simplify the SPD to "protect everything entering the tunnel interface", while policy-based VPNs rely on explicit traffic selectors — the source of many interoperability problems.
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 → IPsec Architecture. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301 · confidence 94%