DumpAny

STUN NAT Traversal — UDP Hole Punching

Speed:
Ready — Click play to start the demo
STUN NAT Traversal — UDP Hole Punching
In P2P communication, devices behind NAT don't know their public address. The STUN protocol uses a simple request-response mechanism that lets clients ask a STUN server, "What's my public IP and port?" — preparing for subsequent UDP hole punching.
🔒 NAT 问题
A 和 B 都在 NAT 后面,不知道公网地址,无法直连
🏢 STUN 作用
公网镜子 — 告诉客户端它的公网 IP:Port
🕳️ UDP 打洞
双方知道地址后同时发包 → NAT 建立映射 → P2P
NATNAT💻Client ANAT: 10.0.0.2🏢STUN Serverstun:3478🖥Client BNAT: 192.168.1.5Binding Request← 1.2.3.4:5555