Insights
NAT traversal: how devices connect across private networks
Learn how NAT traversal uses STUN, TURN and ICE, why direct connections can fail, and what connection details do and don't prove.

On this page
NAT traversal is a set of methods for establishing and keeping connections across routers that use network address translation (NAT). It helps devices on separate private networks communicate. Some methods create a direct path, while others send traffic through a relay when a direct path isn't available.
In short:
- Address discovery. Finding a public-facing address doesn't prove another device can reach it.
- Direct connections. Devices can exchange traffic directly when a usable peer path exists.
- Relayed connections. An intermediary carries the traffic when the application uses a relay.
Why two devices can't always connect directly
Hypothetical example: You and a friend want to share a file between devices on different home networks. Each device has a private Internet Protocol (IP) address used inside its own network. A public-facing address is what an outside server sees. A port identifies a communication endpoint at an address.
Your NAT router translates packet addresses and portsOpens in a new tab, creating a temporary mapping between private and public-facing endpoints. That mapping helps the router send matching return traffic to the right device. For Internet Protocol version 4 (IPv4), incoming packets usually need to be associated with an outbound connection.
Your browser's outbound request can create this mapping before the reply arrives. Your friend's device can't assume that sending traffic to your router's public address will reach your device. Traversal helps the devices find a usable route, but the result varies with the router's mapping behavior.
How the main traversal methods work
Session Traversal Utilities for NAT (STUN) discovers the address and port seen by a server. Traversal Using Relays around NAT (TURN)Opens in a new tab carries traffic through a relay server. Interactive Connectivity Establishment (ICE) gathers and checks possible connection paths, called candidates.
Hole punching here uses User Datagram Protocol (UDP), which sends packets without first establishing a transport connection. Universal Plug and Play (UPnP) lets a device request a port mapping from a compatible local router.
These methods differ in what they set up and whether a server carries your traffic.
| Traversal method | Main job | Traffic path | Main limit |
|---|---|---|---|
| STUN | Discover server-seen address and port | Server used for discovery | Doesn't prove peer reachability |
| UDP hole punching | Use outbound peer traffic to create mappings | Direct when usable | Depends on mapping behavior |
| TURN | Relay traffic between devices | Through relay server | Relay must be reachable and allowed |
| ICE | Gather and check candidate paths | Direct or relayed | Doesn't guarantee a direct path |
| Port forwarding | Configure an inbound mapping | Through configured router | Doesn't configure upstream NATs |
| UPnP | Request a local router mapping | Through compatible local router | Limited to local router scope |
A server used for discovery or setup isn't necessarily in your file's data path. A TURN relay is in that path because it carries the traffic. ICE checks candidate paths, so don't treat it as a guaranteed “STUN first, TURN second” sequence. If your connection crosses several NAT routers, a local port request doesn't control the others.
Why a direct connection can still fail
Direct traversal can fail when a router uses different mappings for different destinations. The older label “symmetric NAT” describes this problem: the mapping found through a STUN server may differ from the one used for your peer. Devices behind the same NAT may also need hairpin support, which routes traffic sent to the public-facing address back inside the network. Without that support, exchanging public-facing addresses may not let those devices connect.
Use the connection details your application shows to separate address discovery from a working traffic path.
| Your observation | Supported meaning | Not proven |
|---|---|---|
| A successful STUN response | Address and port seen by that server | Reachability from your peer |
| A working direct connection | Direct peer traffic works for this session | Success on other networks or later sessions |
| A working relay connection | Traffic works through an intermediary | Direct peer connectivity |
| A connection fails after inactivity | The idle session stopped working | Mapping expiry or a specific fault |
A NAT binding is the stored address-and-port mapping, and it can expire after inactivity. Applications may send periodic outbound keep-alive packets to keep it active. If an idle session fails, check the app's connection status and keep-alive behavior before blaming the router. Mapping expiry is one possibility to investigate, not a diagnosis.
NAT behavior and firewall policy are separate concerns. A relay can provide another path when it's reachable and allowed, but NAT traversal itself doesn't grant permission or encrypt traffic. Check the app's current direct or relay status before naming the path. If it only shows a discovered address, the traffic path remains unconfirmed.
What NAT-T means in IPsec
In Internet Protocol Security (IPsec), NAT-T is a specific form of NAT traversalOpens in a new tab. It wraps Encapsulating Security Payload (ESP) traffic in UDP so NAT can work with the outer address and port.
The router example describes the ports this way:
In other words, RTR-Site1 encapsulates ESP packets inside UDP/4500 for Source and Destination Ports.
That port belongs to this IPsec context, not every NAT traversal method. It isn't a universal instruction to open a firewall port.
Where doxx.net fits. doxx.net offers direct device-to-device connections and full, unmodified file transfer between devices. If that matches your needs, create an account, download the appOpens in a new tab and connect a device or agentOpens in a new tab.