Use this when reading IPsec security associations.
Security Associations
A security association (SA) is a one-way agreement on keys, algorithms and lifetime between IPsec peers, identified by an SPI. Each tunnel has an IKE SA plus a pair of IPsec SAs.
1. SAs are unidirectional; identified by SPI + destination + protocol.
2. Lifetimes by time and bytes.
3. Rekey before expiry.
4. Stale SAs after peer reboot — DPD cleans up.
5. Count matches tunnels.
SPI → SA parameters → packet processing
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
show crypto ipsec sa peer 198.51.100.2Verification & 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 Reading SA output Narrow the fault
show crypto ipsec sa peer 198.51.100.2
#pkts encaps: 1520, #pkts encrypt: 1520
#pkts decaps: 0, #pkts decrypt: 0
Illustrative output, not captured Evidence. Encaps rising but decaps zero means traffic leaves but nothing comes back: check the peer's routing, its SA for the reverse direction and any ACL/NAT on the path. Both zero means traffic never matches the tunnel.
Step 2 Common mistakes Narrow the fault
- Lifetimes and PFS settings mismatched.
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.
- An SA is one-way and identified by an SPI.
- Each tunnel has an IKE SA and a pair of IPsec SAs.
- Lifetimes trigger rekeying.
ip xfrm state— SAs (SPI, algorithms, lifetimes)show crypto ipsec sa— SA detailsswanctl --list-sas— SA state
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
A Security Association (SA) is a one-way agreement between two IPsec peers on how to protect traffic: algorithms, keys, lifetimes and the SPI (Security Parameter Index) that identifies it. Each tunnel needs at least two IPsec SAs (inbound and outbound) plus the IKE SA used to manage them.
show crypto ipsec sa peer 203.0.113.20
show crypto ikev2 sa detailed
ip xfrm state # Linux (strongSwan/libreswan)
swanctl --list-sas
SAs expire by time or data volume and are replaced before expiry (rekey). Counters in the SA output — packets encrypted/decrypted, errors, replay failures — are the most direct way to see whether traffic flows in both directions.
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 → Security Associations. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc4301 · confidence 94%