About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When a NAT device sits between two IPsec gateways, the gateways start talking on UDP 500, discover the NAT, and then move all further IKE and encrypted traffic to UDP 4500. If something in the path passes 500 but not 4500, the first exchange succeeds and the tunnel then stalls. The initiator keeps retransmitting and no tunnel forms.
Capture on UDP 500 and 4500 on the gateway and compare. If packets leave on 4500 and never reach the other side, open UDP 4500 end to end.
What the error means
NAT traversal for IPsec (NAT-T) exists because plain ESP, which is IP protocol 50, does not survive many NAT devices. RFC 7296 says that "firewalls may be configured to pass UDP-encapsulated IPsec traffic but not plain, unencapsulated ESP/AH or vice versa". The standard avoids the problem by wrapping IKE and ESP in UDP.
The sequence in IKEv2 is:
- IKE_SA_INIT on UDP 500. Both sides include NAT_DETECTION_SOURCE_IP and NAT_DETECTION_DESTINATION_IP payloads. Each is "a SHA-1 digest of the SPIs, IP address, and port" of the packet as the sender saw it, so the receiver can compare it with what actually arrived.
- If the values do not match, a NAT is in the path. RFC 7296 says the initiator "MUST tunnel all future IKE and ESP packets associated with this IKE SA over UDP port 4500". It also says "Port 4500 is reserved for UDP-encapsulated ESP and IKE" and that an endpoint that discovers a NAT "MUST send all subsequent traffic from port 4500, which NATs should not treat specially (as they might with port 500)".
- IKE on 4500 carries four zero bytes in front. RFC 7296 says "the IKE header has four octets of zeros prepended". RFC 3948 calls this a Non-ESP Marker, "4 zero-valued bytes aligning with the SPI field of an ESP packet". ESP packets on the same port begin with a non-zero SPI, so the receiver can tell them apart.
Fortinet's community article on IKE negotiation ports 500 and 4500 summarises it: negotiation starts on UDP 500 because a peer cannot know in advance whether a NAT exists. With no NAT, everything stays on 500 and ESP runs as protocol 50. With NAT, both peers switch to 4500 and ESP is encapsulated in UDP 4500.
So the fault looks like this: the first IKE_SA_INIT request and response succeed on 500, then the next IKE message goes to 4500 and nothing answers. IKE is a request and response protocol where the initiator does the retransmitting. RFC 7296 says "the initiator MUST retransmit a request until it either receives a corresponding response or deems the IKE SA to have failed". That gives you repeated identical packets from the initiator on 4500 with no reply.
On the initiating gateway the symptom is repeated IKE requests on UDP 4500 with no reply, and the tunnel never reaches the established state. To check, run a packet capture with the filter udp port 4500 on both gateways at the same time: if packets leave one side and never arrive at the other, something in the path between them is blocking UDP 4500.
This is a different fault from a rejected proposal. A NO_PROPOSAL_CHOSEN reply in IKE_SA_INIT means the other side answered and refused. Here the other side never sees the second message. A tunnel that comes up and then carries no data is a third case, covered separately under a site-to-site IPsec tunnel that is up but passes no traffic.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| A firewall in the path allows UDP 500 but not UDP 4500 | Packets on 500 are answered; packets to 4500 leave the initiator and are not answered | Capture on both gateways: 4500 leaves one side and never arrives at the other |
| The NAT device does not forward UDP 4500 to the gateway behind it | Responder behind NAT never sees the 4500 packets | Capture on the responder's interface shows nothing on 4500 |
| NAT-T disabled on a gateway | A gateway that does not support or has disabled NAT traversal cannot move to 4500 | Check the NAT-T setting on each gateway |
| Idle NAT mapping expired | Tunnel works, then stops until traffic or a rekey | Keepalive interval longer than the NAT timeout |
| Custom IKE port not matched | One side uses a non-standard port and the other expects 500 and 4500 | Compare configured ports on both sides |
Prove the cause before changing anything
All of this is read-only except the optional capture rules. These commands have not been run or lab-tested.
Step 1: see what the gateway thinks
On a Linux gateway running strongSwan, list the connection state with swanctl --list-sas. The page documents it as listing "established IKE SAs and their dependent CHILD SAs". A stalled negotiation shows no established SA. If an IKE SA is established and a child SA is present, the 4500 path is probably working.
For a tunnel that is established, check how ESP is being sent. ip-xfrm(8) documents ip xfrm state list, including the form ip [ -4 | -6 ] xfrm state list [ ID ] [ nokeys ] [ mode MODE ] [ reqid REQID ] [ flag FLAG-LIST ]. The man page gives the syntax that sets UDP encapsulation on a state as encap ENCAP, where ENCAP := { espinudp | espinudp-nonike | espintcp } SPORT DPORT OADDR. In the listing, look for that encapsulation type and its ports. The ip xfrm state count form gives the number of states. The nokeys option appears in the list syntax. The man page does not describe what it does, so before pasting output into a ticket, check on your own system that key material is left out. When encapsulation is in use, expect port 4500 among the ports unless a custom port is set.
Step 2: capture on 500 and 4500
strongSwan documents capturing IKE and ESP using the NFLOG target. It inserts firewall rules that copy the packets to a capture group. For ingress and egress on UDP 500 and 4500:
iptables -t raw -I PREROUTING -p udp -m multiport --dports 500,4500 -j NFLOG --nflog-group 5
iptables -t raw -I OUTPUT -p udp -m multiport --dports 500,4500 -j NFLOG --nflog-group 5
tcpdump -s 0 -n -i nflog:5
The page uses group 5 as an example and says the group number can be changed. To also see plain ESP, it adds iptables -t raw -I PREROUTING -p esp -j NFLOG --nflog-group 5 and the matching rule on OUTPUT.
Risk: these commands insert firewall rules on a live gateway. They only copy packets, but a typing mistake in a rules command can affect traffic. Remove the rules when finished, with the matching iptables delete command or by reloading your saved ruleset. Run them from a console session that will not depend on the tunnel you are testing.
Run the capture on both gateways, then start the tunnel from one side. Read the result against the sequence above:
| On the initiator | On the responder | Meaning |
|---|---|---|
| IKE packets leave on 500 and replies come back | Same packets arrive on 500 | Port 500 is open both ways |
| Further IKE packets leave to 4500, repeated, no replies | Nothing arrives on 4500 | Something between them drops or does not forward 4500 |
| Further IKE packets leave to 4500, repeated, no replies | 4500 packets arrive but no reply leaves | The responder is not answering; check the gateway and its local firewall |
| No packet ever leaves on 4500 | The initiator did not detect a NAT or has NAT-T off |
Ports are not always symmetric. RFC 7296 says IKE packets "MUST be sent to and from UDP port 500 or 4500, they MUST be accepted coming from any port and responses MUST be sent to the port from whence they came", because NATs may change the ports. A firewall rule that insists on source port 4500 on the return path can therefore be too strict.
Step 3: see whether the NAT is real
If a NAT is reported where you did not expect one, compare the source address of the first packet in the capture with the gateway's configured address. A difference means something is translating it.
Step 4: check for a forced or unwanted move to 4500
strongSwan's NAT traversal page says port 4500 is used "when a NAT situation is detected". It also says "ESP-in-UDP encapsulation can be enforced even if no NAT situation exists by setting encap = yes". The page documents mobike = no in the swanctl.conf connection to prevent MOBIKE from moving a connection to 4500 when there is no NAT. A tunnel that stalls on a network with no NAT can therefore be caused by encap = yes or MOBIKE moving to a port the firewall blocks.
Example (illustrative): gateway fw-a at 198.51.100.5 is the initiator, and fw-b sits behind a NAT router. The capture on fw-a shows an IKE_SA_INIT request and response on port 500. It then shows three identical packets to the router's public address on port 4500 at growing intervals, with no replies. On fw-b, nothing arrives on 4500. The router has a port forward for UDP 500 to fw-b at 10.0.20.2 but none for UDP 4500. Adding the forward for 4500 fixes it.
Fix
Open the path for UDP 500 and 4500 between the gateways, and let the gateways do NAT-T.
- Firewalls in the path: allow UDP 500 and UDP 4500 between the two gateway addresses, in both directions. RFC 7296 notes that a firewall may pass UDP-encapsulated IPsec but not plain ESP, or the reverse, so check both rules. Risk: a firewall rule change affects all traffic matching it. Scope the rule to the two gateway addresses, record the old ruleset, and back out by removing the rule you added.
- NAT router in front of a gateway: forward UDP 500 and UDP 4500 to the gateway behind it. strongSwan's page describes a static port forward as a case where keepalives can be turned off with
charon.keep_alive = 0. Risk: forwarding ports exposes the gateway to the Internet on those ports. - NAT-T switched off: enable NAT traversal on the gateway that has it disabled. Check the vendor's documentation for the exact setting. Disruptive step: changing a VPN gateway's settings can drop tunnels that are up. Do it in a maintenance window.
- Idle mappings: keep the NAT mapping alive. RFC 3948 defines the NAT keepalive as a one-octet packet with the value 0xFF, and strongSwan sends keepalives "every 20s" by default. The interval is set by
charon.keep_alivein strongswan.conf. Compare it with the NAT device's UDP timeout. - Custom ports: strongSwan's page says that when a custom server port is in use, "the server must be prepared to process UDP-encapsulated ESP packets on that custom port", and that
charon.port_nat_tis the setting for the NAT-T port. Make both sides agree. - Unwanted 4500: if the network has no NAT and the move to 4500 is the problem, check for
encap = yesand considermobike = no, as documented. Risk: disabling MOBIKE removes its ability to follow address changes.
Confirm the fix
- Repeat the capture on both gateways. After the exchange on 500, you should see IKE packets on 4500 in both directions.
swanctl --list-sasshould list the IKE SA and a child SA.ip xfrm state list nokeysshould list states, showing UDP encapsulation on port 4500 when NAT-T is in use.- Send traffic through the tunnel and watch the packet counts increase.
- Remove the capture rules you added.
What to watch afterwards
- Idle periods. If the tunnel drops overnight and returns with traffic, compare the keepalive interval with the NAT device's timeout.
- Router or firewall changes in front of a gateway. A port forward can disappear with them.
- A new ISP or address change, which can introduce a NAT and trigger the move to 4500.
Read next
Related articles you may want next.
- TroubleshootingIPsec VPN Tunnel Up but No Traffic: Read-Only DiagnosisAn IKEv2 tunnel can be up while no data flows. Check child SAs, selectors, NAT, routing and packet size on both strongSwan gateways before any change.Read article
- TroubleshootingPort Forward Works From the Internet but Not Inside: NAT Hairpin or Split DNSPublic name works outside but not on the LAN? Prove the NAT hairpin fault with captures, then choose hairpin NAT (DNAT plus SNAT) or split DNS with the TLS name intact.Read article
- TroubleshootingSmall Requests Work but Large Transfers Hang: Proving a Path MTU Black HolePing works but large transfers or TLS stall? Prove a PMTU black hole with DF pings and captures, then fix it by allowing ICMP, clamping MSS or lowering MTU.Read article
Risks and limits
- The symptom, repeated requests on UDP 4500 with no reply, follows from RFC 7296, RFC 3947 and RFC 3948 and from vendor descriptions of the port behaviour. The exact log wording differs by gateway.
- The IKEv2 sequence is from RFC 7296. IKEv1 differs in detail. RFC 3947 says the initiator "MUST set both UDP source and destination ports to 4500" at the switch, and that all subsequent packets to the peer, including informational notifications, go to 4500.
- The Fortinet article describes port behaviour in general terms and gives no debug lines or settings. Vendor-specific NAT-T settings are not covered here.
- ip-xfrm(8) lists the options but the page does not explain
nokeys.
Sources
- RFC 7296: Internet Key Exchange Protocol Version 2 (IKEv2) — IETF, October 2014, accessed 17 November 2026
- RFC 3947: Negotiation of NAT-Traversal in the IKE — IETF, January 2005, accessed 17 November 2026
- RFC 3948: UDP Encapsulation of IPsec ESP Packets — IETF, January 2005, accessed 17 November 2026
- NAT Traversal — strongSwan 6.0 documentation, date not shown, accessed 17 November 2026
- Taking Traffic Dumps — strongSwan 6.0 documentation, date not shown, accessed 17 November 2026
- swanctl --list-sas — strongSwan documentation, date not shown, accessed 17 November 2026
- ip-xfrm(8) — Linux man-pages project, date not shown, accessed 17 November 2026
- Technical Tip: Understanding IKE negotiation ports 500/4500 — Fortinet community, 29 August 2025 (page also shows 16 April 2026), accessed 17 November 2026
This article was originally published on .