ikev2 — RFC 7296 VPN Key Negotiation on UDP 500 & 4500
- Default Port / Protocol
- UDP 500 -> 500 (NAT-T 4500)
- Host Endpoint Rule
- Dual-Stack IPv4/IPv6
- Wireshark Display Filter
- isakmp
- Standards & Specs
- RFC 7296, RFC 3948
What It Does on the Wire
Before a single esp packet flows, two VPN concentrators argue about crypto proposals over UDP 500. ikev2 scripts sainit <-> auth handshakes and NAT-T dstport 4500 checks.
Internet Key Exchange Version 2 (ikev2, RFC 7296) performs mutual authentication and establishes IPsec Security Associations over UDP 500 -> 500 (or UDP 4500 -> 4500 when NAT-Traversal is detected). Every IKEv2 packet starts with a 28-byte header containing 64-bit Initiator and Responder SPIs (initiatorspi, responderspi), Next Payload type (nextpayload / nextheader), Version 0x20 (2.0), Exchange Type (34..37), Flags (0x08 Initiator, 0x20 Response), Message ID (msgid), and 32-bit total Length.
FrameAssembly encodes valid IKEv2 headers and chained payload structures across all four RFC 7296 exchange modes (sainit, auth, createchildsa, informational).
VPN Concentrator Firewall & NAT-Traversal (UDP 4500) Audits
Test UDP 500 initial sainit negotiation transitioning to srcport 4500 dstport 4500 auth exchanges across enterprise edge firewalls.
Dead Peer Detection (DPD) & Rekey Lifecycle Simulation
Craft informational DPD probes (flags 0x08 -> flags 0x20) and createchildsa rekey exchanges with incrementing msgid values.
Unauthorized VPN / Shadow Tunnel NDR Detection
Generate Zeek/Suricata test captures flagging unexpected outbound IKEv2 SA_INIT handshakes from internal server subnets.
RFC Wire Header Layout (ikev2)
Select any 32-bit wire word or field slice below to inspect which .frasm modifiers control those octets and what defaults the compiler writes.
Filter with isakmp and check UDP 500 (or UDP 4500 NAT-T) to verify Initiator SPI, Responder SPI, Exchange Type (IKE_SA_INIT vs IKE_AUTH), and transform payloads.
Minimal Quickstart (ikev2_quickstart.frasm)
Select Preview Packets to compile in-browser and inspect timestamps + wire byte lengths, or open directly in the Playground.
host initiator { ip 198.51.100.10 }
host responder { ip 203.0.113.20 }
compile {
initiator -> responder ikev2 sainit initiatorspi 0xa1b2c3d4e5f60708 msgid 0 wait 3ms
initiator <- responder ikev2 sainit initiatorspi 0xa1b2c3d4e5f60708 responderspi 0x1122334455667788 flags 0x20 msgid 0
}Handled Automatically on the Wire
- Defaults both
srcportanddstportto IANA IKE port500(avoiding ephemeral49152source ports blocked by strict VPN ACLs). - Writes the 28-byte RFC 7296 IKEv2 header (
Version 0x20, exact 32-bitLength, 64-bit SPIs) and defaultsresponderspito0onsainitrequests. - Accepts exchange modes either bare (
ikev2 auth) or prefixed (ikev2 exchange auth), and treatsnextheaderandnextpayloadas exact synonyms.
IKEv2 SA_INIT on UDP 500 Floating to NAT-Traversal UDP 4500 + DPD Check
Traces a complete IKEv2 phase: SA_INIT on UDP 500, NAT-T port float to UDP 4500 for encrypted IKE_AUTH (nextpayload 46), and an INFORMATIONAL Dead Peer Detection exchange.
host branch_fw { ip 198.51.100.15 }
host cloud_vpn { ip 203.0.113.99 }
compile {
// 1. IKE_SA_INIT on UDP 500 -> 500 (Next Payload 33 = Security Association)
branch_fw -> cloud_vpn ikev2 sainit initiatorspi 0x9080706050403020 responderspi 0 msgid 0 flags 0x08 nextpayload 33 wait 4ms
branch_fw <- cloud_vpn ikev2 sainit initiatorspi 0x9080706050403020 responderspi 0x0102030405060708 msgid 0 flags 0x20 nextpayload 33 wait 4ms
// 2. Float to UDP 4500 for IKE_AUTH (Next Payload 46 = Encrypted & Authenticated SK)
branch_fw -> cloud_vpn ikev2 auth srcport 4500 dstport 4500 initiatorspi 0x9080706050403020 responderspi 0x0102030405060708 msgid 1 flags 0x08 nextpayload 46 wait 5ms
branch_fw <- cloud_vpn ikev2 auth srcport 4500 dstport 4500 initiatorspi 0x9080706050403020 responderspi 0x0102030405060708 msgid 1 flags 0x20 nextpayload 46 wait 50ms
// 3. INFORMATIONAL Dead Peer Detection (DPD) liveness check
branch_fw -> cloud_vpn ikev2 informational srcport 4500 dstport 4500 initiatorspi 0x9080706050403020 responderspi 0x0102030405060708 msgid 2 flags 0x08 nextpayload 46 wait 3ms
branch_fw <- cloud_vpn ikev2 informational srcport 4500 dstport 4500 initiatorspi 0x9080706050403020 responderspi 0x0102030405060708 msgid 2 flags 0x20 nextpayload 46
}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show ikev2_natt_dpd.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly ikev2_natt_dpd.frasm ikev2_natt_dpd.pcap
frameassembly ikev2_natt_dpd.frasm ikev2_natt_dpd.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse ikev2_natt_dpd.pcap ikev2_natt_dpd_edited.frasm
# 4. Verify dissected protocol fields in tshark
tshark -r ikev2_natt_dpd.pcap -Y "isakmp"All ikev2 Keywords & Header Options
Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after ikev2:
src_host -> dst_host ikev2 [exchange <sainit|auth|createchildsa|informational> | sainit | auth | createchildsa | informational] [initiatorspi <u64|"hex">] [responderspi <u64|"hex">] [msgid <number>] [flags <0..255>] [nextpayload|nextheader <0..255>]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| sainit | auth | createchildsa | informational | exchange <...> | RFC 7296 Exchange Type keyword or u8 | sainit (34) | Sets Exchange Type: sainit (34 IKE_SA_INIT), auth (35 IKE_AUTH), createchildsa (36 CREATE_CHILD_SA), informational (37 INFORMATIONAL). |
| initiatorspi <u64|"hex"> | responderspi <u64|"hex"> | 64-bit integer or hex string | Deterministic initiator SPI; responderspi 0 on sainit | Populates the 8-byte Initiator SPI and 8-byte Responder SPI in the IKEv2 header. |
| msgid <number> | Whole number | 0 | Sets the 4-byte IKEv2 Message ID (0 for sainit, 1 for initial auth, incrementing per request/response pair). |
| flags <0..255> | 8-bit bitmask | 0x08 (Initiator) | Sets RFC 7296 Flags (0x08 = Initiator I, 0x10 = Version V, 0x20 = Response R; responder replies to initiator typically use 0x20). |
| nextpayload <0..255> | nextheader <0..255> | 8-bit IKEv2 Payload Type | 33 (SA) or 0 (None) | Sets the first chained IKEv2 Payload Type (33 SA, 34 KE, 40 Nonce, 46 Encrypted SK, 0 None). |
Cross-Layer Wrappers Valid with ikev2
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
10 options
Cross-Layer Wrappers Valid with ikev2
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums. |
| srcmac <mac> | dstmac <mac> | ethertype <0..65535> | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | Host MAC / RFC multicast MAC / auto EtherType | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType for this single packet. |
| vlan <0..4095> [pcp <0..7>] [dei <0|1>] | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | Untagged | Wraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority. |
| qinq <0..4095> [innervlan <0..4095>] | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | Untagged (innervlan 1 when qinq is set) | Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100). |
| mpls <0..1048575> [label <0..1048575>] [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (at most 1 mpls tag per packet) | Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header. |
| ttl <0..255> [dscp <0..63>] [ecn <0..3>] | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | ttl 64, dscp 0, ecn 0 | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| ipid <0..65535> [df] [mf] [fragoffset <0..8191>] | IPv4 ID, DF/MF flags, fragment offset 0..8191 | ipid 1, flags 0, fragoffset 0 | Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6). |
| flowlabel <0..1048575> | 20-bit IPv6 Flow Label (0..1048575) | 0 | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| srcport <0..65535> | dstport <0..65535> | Port number 0..65535 | srcport 49152 (remembered), UDP 500 -> 500 (NAT-T 4500) | Overrides source or destination port and remembers the port pair automatically on <- replies. |
Gotchas & Quick Fixes
Zero Underscores in Exchange Modes
a -> b ikev2 sa_init // or create_child_saa -> b ikev2 sainit // or createchildsaExchange modes follow the strict lowercase alphanumeric rule: sainit, auth, createchildsa, informational.
Set flags 0x20 on Responder Replies
a <- b ikev2 sainit initiatorspi 0x1122 responderspi 0x3344 flags 0x20On responder replies (<-), setting flags 0x20 sets the RFC 7296 Response (R) bit and clears the Initiator (I) bit so Wireshark labels the packet (Response).