Connection paths and NAT
Two devices that talk through XplicitTrust can be connected in three ways: through a relay, directly across the internet, or directly inside one local network. This page explains the paths, why a direct one is better, and what the NAT in front of a device has to do with it.
In short
A connection always starts through a relay and switches to a direct path when the two devices can reach each other. UDP is the preferred transport; if it is blocked, the agent falls back to a relay over TCP 443. Direct connections need the firewall to keep the agent's UDP source port.
The three paths
The connection paths fall into a hierarchy, from the one that always works to the best one:
| Path | What happens | Shown in the console as |
|---|---|---|
| Relayed | The traffic of both devices goes through an XplicitTrust relay. It works wherever both devices can reach the relay. It adds latency. | Relayed Connection |
| Direct | The two devices send their packets to each other across the internet, without a relay. | Direct Connection |
| Direct, local | Both devices are on the same local network and talk to each other there. | Local Connection |
All three are end-to-end encrypted. A relay forwards encrypted packets and never has access to their contents; see the Security Model.
How a connection moves to a better path
- Both peers connect through the relay first, so the connection works from the first packet.
- All clients and assets are connected to the Broker. The Broker classifies how each device is connected to the internet (see NAT types) and orchestrates attempts to find a direct connection between the peers.
- If a direct connection is possible, the peers switch and send traffic directly.
The steps are numbered in How XplicitTrust works. The Insights pages of the Admin Console show the path of every connection (see Insights).
UDP and the TCP 443 fallback
XplicitTrust uses WireGuard over UDP as its preferred transport. A device reaches its peers either directly or through a UDP relay. If UDP becomes unavailable or unstable, the agent automatically fails over to a TCP relay, which carries the traffic as TLS over TCP port 443. The TCP fallback keeps the connection working, but adds latency and overhead.
| Transport | Ports | Used for |
|---|---|---|
| UDP | Outgoing 51820 to 60000 |
Direct connections and the UDP relay |
| TCP | Outgoing 443 |
Registration, the API, the Broker and the TCP relay |
The complete list of what your firewall has to allow is in Settings and Requirements. What a firewall can do to this traffic, and how to fix it, is in Firewalls, Proxies and TLS Inspection.
Hole punching
To connect two devices that both sit behind a NAT, the Broker arranges that both of them send UDP packets to each other, one device starting and the other answering. An outgoing packet opens a mapping in the sender's NAT, so the reply of the other side is let in. This is called UDP hole punching.
It works only if the NAT puts the packet on the port the Broker expects. A firewall that rewrites the source port of the agent's UDP packets makes the direct path fail, and the connection stays on the UDP relay.
NAT types
The Broker tests how the NAT in front of every device behaves and keeps the result as the NAT type. The Admin Console shows it as Connectivity in the details of an Asset, and marks a NAT that limits connectivity with the NAT column; see Assets.
| NAT type | What it means | Direct connection |
|---|---|---|
| No NAT, direct connection | No NAT, or a NAT that lets unsolicited packets in and keeps the port | Works |
| Collaborative NAT | A packet is let in once the device has sent one out first, and the port is kept | Works |
| Half-collaborative NAT | Like collaborative, but the NAT is sensitive to which packet comes first: an incoming packet before the outgoing one spoils the mapping. The Broker therefore lets this device start | Works, with the device starting |
| Non-collaborative NAT | The NAT rewrites the UDP source port | Often fails; the traffic stays on the UDP relay |
| Symmetric NAT | The NAT uses a different external port for every destination, common with carrier-grade NAT | Not possible, the connection is relayed |
| UDP traffic filtered, traffic filtered | Outgoing UDP does not get through | Not possible, the connection is relayed |
| Sending error | The agent could not send the test packet, for example because of a local firewall on the device | Not possible, the connection is relayed |
If a device reports Non-collaborative NAT, check the firewall: the usual
cause is source-NAT port translation that does not preserve the agent's port.
xtna-util --status shows the active data path and the NAT type observed on
the device; see the xtna-util reference.
Reclassify NAT in the details of an Asset runs the test again, for example
after you changed the firewall.
Fixed ports
By default an agent chooses its UDP port dynamically. For an Asset behind a firewall that you control, you can Fixate the port in the Admin Console and configure a port forwarding for it, so that peers can reach it directly. The Fixated column of the Assets list shows which Assets have a fixed port; see Assets.
See also
- Concept: How XplicitTrust works, Security Model
- Troubleshooting: Firewalls, Proxies and TLS Inspection
- Reference: Assets, Insights, xtna-util