Use this when an IPsec tunnel does not come up or pass traffic.
IPsec Troubleshooting
IKE → auth → child SA → data path
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ip xfrm statePrimary Commands
Configuration and operational commands for this Topic.
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 Verify IPsec with IKE/child-SA identity and bidirectional protected-packet counters Verify boundary
Verify IPsec by capturing IKE state Established and the expected child-SA local/remote selectors with active SPIs. Send one bounded protected flow and expect encrypt and decrypt packet counters to increase from their recorded baseline with replay/authentication errors at 0, then repeat the original application request through the tunnel. An established IKE SA shows peer authentication and key negotiation, but it does not show the correct child selector, routing choice or remote application path.
Step 2 Branch IPsec troubleshooting at IKE reachability, authentication, child-SA creation and encrypted traffic Narrow the fault
If IPsec has no IKE exchange, verify peer routing and UDP 500/4500 reachability. If IKE starts but authentication fails, inspect peer identity, PSK or certificate chain and clock state. If IKE is Established but no child SA appears, compare encryption/integrity proposals and traffic selectors. If child SAs exist but encrypt counters remain 0, inspect routing and interesting-traffic match. If encrypt rises but decrypt stays 0, capture the return path, NAT-T and remote selector state before clearing SAs.
Step 3 Common mistakes Narrow the fault
- Debugging IPsec before checking IKE.
- Most failures are proposal or selector mismatches.
- NAT needs UDP 4500.
- Routing must send traffic into the tunnel.
swanctl --log / debug crypto ikev2— negotiation logsshow crypto ipsec sa— countersping -M do -s 1400 <remote>— MTU through tunnel
ReferenceWhy it matters1 section · depth on demand
IPsec separates IKE peer state from child SA selectors, keys and encrypted packet counters
IPsec troubleshooting should treat IKE and ESP/AH data security associations as separate state machines. IKE authenticates peers and negotiates key material, while child SAs own traffic selectors, transforms, lifetimes and packet protection. A healthy IKE SA can coexist with no child SA because selectors or proposals differ, and a child SA can exist while routing sends traffic elsewhere. Record peer IDs, IKE version, proposal, child selectors, SPI values and encrypt/decrypt counters before clearing IPsec state.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
IPsec troubleshooting proceeds layer by layer: reachability, IKE negotiation, IPsec SA creation, then traffic flow.
| Stage | Symptom | Check |
|---|---|---|
| Reachability | No IKE packets answered | UDP 500/4500 and ESP allowed; NAT in path |
| IKE | No IKE SA | Proposals, PSK/certificates, identities, clock (certificates) |
| Child SA | IKE up, no IPsec SA | Traffic selectors, PFS group, transform sets |
| Traffic | SA up, no traffic | Routing into tunnel, NAT exemption, firewall policy, MTU |
| Stability | Drops at rekey | Lifetime/PFS mismatch, DPD settings |
show crypto ikev2 sa
show crypto ipsec sa | include pkts|errors
show crypto session detail
swanctl --list-sas
journalctl -u strongswan --since "10 min ago"
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 Troubleshooting. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301 · confidence 94%