# Configure a relay

> Let devices on different networks or behind NAT reach each other through a relay you run.

Devices on the same local network reach each other directly, so a fleet in a single office doesn't need a relay. You need one when some devices can't reach the others, for example when:

- Your devices are spread across offices or sites on separate networks
- Employees take laptops home or travel, and you want those laptops to keep serving

## How a relay works

Each device keeps an outgoing connection open to the relay, so nothing needs to reach the device from outside. When two devices can't connect directly, the relay links them, then helps them switch to a direct connection where the network allows.

- **Private:** traffic through the relay is encrypted between the two devices, so the relay can't read prompts or replies.
- **Only your fleet:** a relay accepts only devices in your organization.
- **Slower than direct:** relayed connections add delay. A model split across several PCs runs best on devices that share a network.
- **Not billed as a device:** relays don't count toward your plan's device limit.

You can run up to five relays, for example one near each region, or a second for redundancy.

## Before you start

You need a host with a public IPv4 address running Ubuntu 22.04 or later on 64-bit Intel/AMD, such as a small VPS. Devices must be able to reach it on the relay's port over UDP and TCP; the console shows the port once the relay enrolls.

## Add a relay

1. In the console, open **Devices → Add device** and choose **Relay**.
2. Leave **Public address** blank if the relay connects from its own public IP, as on most cloud hosts. Fill it in if the relay sits behind a load balancer or reaches the internet from a different address.
3. On the relay host, install the downloaded package, or paste the block into a terminal and enter your `sudo` password.

The relay enrolls and appears on **Devices → Relays** within a minute. Devices start using it on their next check-in, usually within two minutes, and the row shows how many it's serving.

## If it shows "not reachable"

Devices are online but none can reach the relay. Check that the advertised address is right, then that the relay's port (shown in the console) is open for UDP and TCP in both the host and cloud firewalls.

## Replace a relay

To move a relay to a new address or re-install it after an upgrade, select **Re-enrol** on its row and run the new block on the same host. It keeps its identity.

A revoked relay can't come back. Run `sudo cascadia-relay teardown --yes` on its host, then add a new one.
