Home Page

VPN & Cryptography


Email & Spam

Security Terminology


VPN Terminology

VPN Tutorial Guide



Aggressive Mode

Authentication Header

Asymmetric Encryption


Certification Authority

Data Integrity



Digital Certificate

Dynamic IP addresses





IPSec Quick Mode


Main Mode







Pre-Shared Key

Remote Access User


Security Association


Site to Site VPN


Transform Sets

Tunnel mode and Transport mode

VPN client tunneling option

VPN Topologies

VPN Tunnel


NAT Traversal - IPSec over NAT Tutorial



Nat Traversal, also known as UDP encapsulation, allows traffic to get to the specified destination when a device does not have a public IP address. This is usually the case if your ISP is doing NAT, or the external interface of your firewall is connected to a device that has NAT enabled.

As well as IPsec providing confidentiality, it also provides authenticity and integrity. Now the problem is when a NAT device does its NAT translations, the embedded address of the source computer within the IP payload does not match the source address of the IKE packet as it is replaced by the address of the NAT device. This means breaking the authenticity which will cause the packet by the remote peer to be dropped. So when the NAT device alters the packet, its integrity and authentication will fail.

Also in some cases, depending on the level of encryption, the payload and in particular the headers are encrypted when using IPsec ESP mode. The NAT device cannot change these encrypted headers to its own addresses, nor do anything with them.

The NAT device in the middle breaks the authenticity, integrity and in some cases cannot do anything at all with the packet. It is clear NAT and IPsec are incompatible with each other, and to resolve this issue, NAT Traversal was developed. NAT Traversal adds a UDP header which encapsulates the IPsec ESP header. As this new UDP wrapper is NOT encrypted and is treated just like a normal UDP packet, the NAT device can make the required changes and process the message, which would now circumvent the problems explained above. Additionally, enabling NAT-Traversal on the gateway devices resolves the problem with the authenticity and integrity checks, as they are now aware of these changes.

To explain things a bit further, during phase 1 negotiation of an IPsec VPN connection, if NAT Traversal is used one or both VPN peer devices identify to each other that they are using NAT Traversal, and it is then when the IKE negotiations switch to using UDP port 4500 to support it. After this the data is sent and handled using IPsec over UDP, which is effectively NAT Traversal. The receiving peer first unwraps the IPsec packet from its UDP wrapper (the NAT Traversal part that occurred at the sending peer end) and then processes the traffic as a standard IPsec packet.

IPsec NAT Traversal Ports

Three ports in particular must be open on the device that is performing NAT for the VPN to work correctly. These ports are UDP port 4500 (used for NAT traversal), UDP port 500 (used for IKE) and IP protocol 50 (ESP).

The ultimate fix to NAT-Traversal is to use a public IP address on the firewall’s external interface. This is also the recommended method, and will eliminate the use and need of NAT-Traversal.

Further Reading

Wikipedia's guide to NAT-T