I just read an article about the process of "punching holes" with the UDP protocol. I understand how it's done, but I have one last question to clear up things. We have the rendezvous server and client A,B.

Client A punched a hole already for client B. Client B receives the NAT IP and the NAT port from the rendezvous server and starts to send data to the same port as the rendezvous server. Let's say I happen to know a second port the NAT has open for UDP connections. Could I send my packets through this second port also? Or is the port distinguished for every outgoing UDP connection? If so, how come we can use the same port for Client B and the rendezvous server? Wouldn't the NAT open a new port when Client A punches the hole and Client B had to know what new port the NAT opened for this specific connection?

I hope my question is somewhat understandable.

1 Answer 1


The NAT device will keep a table with currently open connections so that it can send return packets to the internal host that opened the connection. An entry in the state table could look something like this:

Internal Source IP | Internal S-Port | External S-Port | Destination IP | D-Port         10123             10123         5555

When a packet is received (from the external side) the NAT device will check the Source IP, Source Port and Destination Port of the packet and compare it to the Destination IP, D-Port and External S-Port fields in its connection table. When it finds a match it will forward the packet to Internal Source IP on Internal S-Port.

UDP hole punching depends on the fact that Internal and External Source Ports are the same. This is normally the case unless you have a second internal host that uses the same Source port to connect to the same external Destination/D-Port combination.

When we assume that Internal and External S-Port are the same then both clients A,B can communicate their source port to the rendezvous server which will then relay the information back to the other client respectively.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.