I have the following two problems. Please help me to solve them:

  1. In symmetric NAT, as I know, the local hidden node (behind the NAT) must initiate connection in order to create a window in the NAT to allow the packets of the remote host back into the local network. Can somebody give me some idea how i can do this?

  2. How can an application learn that there are NATs in the path between the source and the destination?

2 Answers 2


I can give you a place to start for (2): Michal Zalewski's p0f passive monitoring tool. It seems to support some way of guessing that the source of a TCP "SYN" is behind a NAT.


Since UDP is connection-less, NAT implementation cannot know where UDP communication actually ends, so it just creates translation table entry on first passed packet. For example, hidden host with IP send packet to host via NAT router with address, source port is 10000, destination - 20000. On packet arrival NAT creates entry such as this: 10000 - 10000 - 20000

Port number in second field may be different if it is already used by other translation entry. After this entry created, all UDP packets from to will be redirected to

On second question: if there is a NAT between source and destination, remote addresses reported by getpeername(2) and reported directly by remote end (in UDP payload) will be different.

There are more info and links about NAT hole punching on wikipedia.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .