NextGen Sarkari

Study material for government exam preparation across Punjab and India.

Home/Study Material/Networking & Technical/IPsec VPN and IKEv2 Complete Guide
Security & Services study guide

IPsec VPN and IKEv2 Complete Guide

IPsec protects IP traffic with authentication, integrity, anti-replay controls and optional encryption. IKEv2 negotiates the cryptographic parameters, authenticates peers and creates the security associations used to carry protected traffic.

Security & ServicesAdvanced42 min readUpdated 2026-08-06

IPsec architecture and building blocks

IPsec is an architecture rather than one encryption algorithm. A policy decides which traffic must be protected, bypassed or discarded. Security Associations (SAs) describe one-way protection parameters such as algorithms, keys, sequence state and lifetime.

ComponentPurpose
IKEv2Negotiates algorithms, performs key exchange, authenticates peers and creates IKE/IPsec SAs.
ESPProvides confidentiality when encryption is selected, plus integrity/authentication and anti-replay protection.
AHProvides integrity/authentication without encryption; uncommon across NAT because address changes affect authentication.
SPDSecurity Policy Database decides protect, bypass or discard behaviour.
SADSecurity Association Database stores active SA parameters.

ESP is IP protocol 50 and AH is protocol 51. IKE normally starts on UDP 500. When NAT traversal is detected, IKE and encapsulated ESP commonly use UDP 4500.

Transport and tunnel modes

ModeProtected contentCommon use
TransportProtects the upper-layer payload while retaining the original IP header.Host-to-host or as part of specialised designs.
TunnelProtects the entire original IP packet and adds a new outer IP header.Site-to-site gateways and remote-access VPNs.

In a site-to-site tunnel, the outer header routes between VPN peers while the protected inner addresses identify the communicating private networks.

IKEv2 exchange

IKE_SA_INIT
IKE_AUTH
CREATE_CHILD_SA
INFORMATIONAL
  • IKE_SA_INIT: negotiates algorithms, exchanges nonces and performs Diffie–Hellman key exchange.
  • IKE_AUTH: authenticates identities and creates the first CHILD_SA.
  • CREATE_CHILD_SA: creates/rekeys CHILD_SAs or rekeys the IKE SA.
  • INFORMATIONAL: deletes SAs, reports errors and carries liveness-related exchanges.

Authentication can use pre-shared keys, certificates or EAP methods depending on the deployment. Certificates scale better for many peers but require correct trust, identity, validity and revocation handling.

Proposals, identities and selectors

Both peers must agree on cryptographic proposals. Modern designs prefer authenticated-encryption algorithms such as AES-GCM or a strong encryption/integrity combination, suitable Diffie–Hellman groups and secure pseudorandom functions. The exact acceptable suite should follow current organisational and vendor security guidance.

Traffic selectors define which inner source/destination ranges and protocols belong to a CHILD_SA. A common site-to-site failure occurs when one peer proposes different local/remote subnets, protocol scope or port range.

Identity is not always the public IP: A peer can authenticate with an FQDN, certificate subject/SAN, user identity or configured key ID. Match the peer's expected local and remote IDs exactly.

Packet flow and NAT traversal

  1. A packet matches the outbound VPN policy/selectors.
  2. The device finds or negotiates an IPsec SA.
  3. ESP protects and encapsulates the inner packet.
  4. The outer packet is routed toward the peer.
  5. The peer verifies anti-replay/integrity, decrypts and performs an inner route/policy lookup.

NAT detection hashes endpoint address/port information during IKE. When NAT is present, UDP encapsulation allows ESP to cross devices that cannot track native ESP reliably. Firewall policy must permit UDP 500 and 4500 as needed; native ESP may also be required when NAT-T is not used.

Configuration concepts and checks

Vendor-neutral configuration checklist
Peer address / hostname
Local and remote IKE identities
IKEv2 proposal: encryption, PRF, integrity, DH group
Authentication: PSK, certificate or EAP
IPsec/ESP proposal
Local and remote traffic selectors
SA lifetimes and rekey behaviour
NAT exemption / routing / firewall policy
Dead-peer detection or liveness settings
Typical verification areas
IKE SA state and authenticated identities
CHILD/IPsec SA inbound and outbound SPIs
Encryption/decryption packet counters
Replay, integrity and policy-drop counters
Routing and NAT policy
Packet capture on UDP 500/4500 and inner interfaces
Peer logs with timestamps aligned

Phase-by-phase troubleshooting

  1. No IKE response: check peer address, UDP 500/4500, routing, upstream NAT and service state.
  2. NO_PROPOSAL_CHOSEN: compare encryption, integrity, PRF, DH and IPsec transform support.
  3. Authentication failed: check PSK, trust chain, certificate time, ID/SAN and EAP credentials.
  4. IKE up but no CHILD_SA: compare traffic selectors and IPsec proposal.
  5. SAs up but no traffic: check routes, policy, NAT exemption, inner firewall and return path.
  6. Only one direction increments: investigate selector mismatch, asymmetric routing or remote policy.
  7. Intermittent drops: inspect rekey overlap, MTU/fragmentation, replay windows, DPD and NAT timeout.

Interview focus

Use these points to practise concise, operations-focused answers. Explain the concept first, then give a verification or troubleshooting example.

  • What is the role of IKEv2? It negotiates algorithms and keys, authenticates peers and creates IPsec security associations.
  • Which UDP ports are commonly used by IKE and NAT-T? UDP 500 for IKE and UDP 4500 when NAT traversal is used.
  • Are IPsec SAs bidirectional objects? An SA is unidirectional, so protected two-way traffic uses inbound and outbound SAs.
  • What are traffic selectors? The source/destination and protocol scope protected by a CHILD_SA.
  • Why can a tunnel be up but data still fail? Routing, NAT, selectors, firewall policy or return-path issues may remain even when negotiation succeeded.

Quick self-check

1. What is the role of IKEv2?
Answer: It negotiates algorithms and keys, authenticates peers and creates IPsec security associations.
2. Which UDP ports are commonly used by IKE and NAT-T?
Answer: UDP 500 for IKE and UDP 4500 when NAT traversal is used.
3. Are IPsec SAs bidirectional objects?
Answer: An SA is unidirectional, so protected two-way traffic uses inbound and outbound SAs.
4. What are traffic selectors?
Answer: The source/destination and protocol scope protected by a CHILD_SA.
5. Why can a tunnel be up but data still fail?
Answer: Routing, NAT, selectors, firewall policy or return-path issues may remain even when negotiation succeeded.

Frequently asked questions

1. Is IKEv2 the same as IPsec?
Answer: No. IKEv2 negotiates and manages SAs; IPsec protocols such as ESP protect the actual data.
2. Does IPsec require certificates?
Answer: No. It can use pre-shared keys, certificates or EAP-based authentication depending on the design.
3. What is an SPI?
Answer: A Security Parameters Index identifies the receiving SA together with protocol and destination context.

Standards and further reading

Editorial note: Standards explain protocol behaviour, while commands and defaults can differ by vendor, platform and software release. Verify production changes against current vendor documentation.

Continue learning