Hacker News new | ask | show | jobs
by paxys 779 days ago
Device A sends a request to the STUN server. STUN server responds with the public IP address, port and other NAT details that it is able to see. Device A forwards this info to device B, and periodically sends keepalive packets so the connection remains active. Device B is now able to hit device A's public IP/port directly (the router/firewall thinks that the packets are coming from the STUN server).

If the NAT is more restrictive then a TURN server can act as a middleman to relay the packets between device A and device B.