Address translation
UDP hole punching
Two peers behind NAT sending to each other at once, so each router takes the other's packets for replies.
Each peer learns the other's public address and port (from STUN, through a rendezvous server) and sends to it from the same port. Its own router now has an entry expecting replies from the peer, so the peer's packets, arriving at the same time, get in. The first packets may be lost before both entries exist, and the hole closes when the entry times out unless keepalives keep it open. WebRTC, VoIP, games and Tailscale connect this way. Behind a symmetric NAT it fails, and traffic goes through a relay (TURN, RFC 8656), which always works but costs a detour.
Read next
- STUN A server that tells a device behind NAT the public address and port its packets arrive from.
- NAT mapping and filtering Whether a NAT keeps one public port per inside port (friendly to peer-to-peer) or picks one per destination.
- Stateful firewall A firewall that remembers connections, so it can allow replies while refusing new connections in.
- NAT traversal Getting traffic through NAT: wrapping protocols in UDP, whose ports NAT can map, and punching holes between peers.