3.1. Detecting Support of NAT-Traversal
The NAT-Traversal capability of the remote host is determined by an
exchange of vendor ID payloads. In the first two messages of Phase
1, the vendor id payload for this specification MUST be sent if
supported (and it MUST be received by both sides) for the NAT-
Traversal probe to continue. The content of the payload is the MD5
hash of
RFC 3947
The exact content in hex for the payload is
3.2. Detecting the Presence of NAT
The NAT-D payload not only detects the presence of NAT between the
two IKE peers, but also detects where the NAT is. The location of
the NAT device is important, as the keepalives have to initiate from
the peer "behind" the NAT.
To detect NAT between the two hosts, we have to detect whether the IP
address or the port changes along the path. This is done by sending
the hashes of the IP addresses and ports of both IKE peers from each
end to the other. If both ends calculate those hashes and get same
result, they know there is no NAT between. If the hashes do not
match, somebody has translated the address or port. This means that
we have to do NAT-Traversal to get IPsec packets through.
If the sender of the packet does not know his own IP address (in case
of multiple interfaces, and the implementation does not know which IP
address is used to route the packet out), the sender can include
multiple local hashes to the packet (as separate NAT-D payloads). In
this case, NAT is detected if and only if none of the hashes match.
The hashes are sent as a series of NAT-D (NAT discovery) payloads.
Each payload contains one hash, so in case of multiple hashes,
multiple NAT-D payloads are sent. In the normal case there are only
two NAT-D payloads.
The NAT-D payloads are included in the third and fourth packets of
Main Mode, and in the second and third packets in the Aggressive
Mode.