# Run your own relay

import { Callout } from "nextra/components";

<Callout type="info">
  A relay gives each of your computers an address that works from any network, so your [phone](/docs/phone) and [other computers](/docs/your-computers) reach it from anywhere.
</Callout>

You don't need your own relay. Pane's relays can't read your traffic ([here's why](/docs/how-it-connects#each-computer-gets-its-own-address)). Run your own if you'd rather your connections pass through a machine you control. It takes about five minutes, and everything works the same afterward. Push alerts need extra setup, covered in the full guide (below).

## What you need

- **A Linux machine with a public IPv4 address**, such as a small cloud VM. This guide uses `203.0.113.10`. Use your machine's address, as its cloud console shows it.
- **Node.js 22.23.4+, 24.22.1+ or 26.12.1+** for `npx runpane`.
- **A name under a domain whose DNS you manage**, such as `relay.example.com`. The relay answers DNS for every name under it, so pick a name you use for nothing else.
- **Pane 2.4.227 or later** on your computers.

## Set it up

1. **Get your exact commands.** Run this anywhere with your own name and address. It prints the DNS records, ports and commands for your setup, then checks them. The checks fail until you finish step 5.

   ```bash
   npx --yes runpane@latest relay init --domain relay.example.com --public-ip 203.0.113.10
   ```

2. **Open the ports.** In the machine's firewall or cloud security group, allow **TCP 443** and **UDP and TCP 53**. **UDP 7842** is optional and helps devices find direct paths.

3. **Add two DNS records** at the DNS provider for `example.com`:

   | Name | Type | Value |
   |---|---|---|
   | `relay-ns.example.com` | A | `203.0.113.10` |
   | `relay.example.com` | NS | `relay-ns.example.com` |

   The A record points `relay-ns` at your machine. The NS record hands `relay.example.com` and every name under it to your relay.

   Many providers want only the part before your domain in the Name field (`relay-ns`, `relay`). On Cloudflare, set the A record to **DNS only** (grey cloud). A proxied record breaks it.

4. **Free port 53** (Ubuntu and Debian). The system's own DNS helper holds it. This turns that listener off and keeps the machine's lookups working:

   ```bash
   sudo mkdir -p /etc/systemd/resolved.conf.d
   printf '[Resolve]\nDNSStubListener=no\n' | sudo tee /etc/systemd/resolved.conf.d/pane-relay.conf
   sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
   sudo systemctl restart systemd-resolved
   ```

5. **Start the relay** on the machine. `runpane relay` downloads the checksummed `pane-relay` binary from Pane's GitHub release and runs it. Ports 443 and 53 need root. Passing your `PATH` through `sudo` finds `npx` when Node.js came from nvm:

   ```bash
   sudo env "PATH=$PATH" npx --yes runpane@latest relay \
     --domain relay.example.com --public-ip 203.0.113.10 --ns relay-ns.example.com \
     --dns 0.0.0.0:53 --direct-quic 0.0.0.0:7842 \
     --acme-cache /var/lib/pane-relay/acme
   ```

   Keep it running as a service, such as with systemd. Pin a version there (2.4.227 or later, such as `runpane@2.4.229`) so a restart doesn't upgrade it by surprise.

6. **Check it.** Run the `relay init` command from step 1 again. Once DNS has spread (usually a few minutes), every line shows ✓:

   ```text
   ✓ relay-ns.example.com A 203.0.113.10
   ✓ relay.example.com NS relay-ns.example.com
   ✓ relay.example.com A 203.0.113.10, answered by the relay
   ✓ https://relay.example.com/healthz
   ```

   The relay gets its certificate from Let's Encrypt about a minute after DNS works. Until then, the last check says the certificate isn't trusted yet.

7. **Point Pane at it.** On each computer, open **Settings → Remote Access → Phones and glasses → Relay address**, type `relay.example.com` and press Enter.

Your computer reconnects through your relay and new QR codes use your domain.

<Callout type="warning">
  Computers link only with computers on the same relay, so switch every linked computer. Phones paired through Pane's servers need one new scan.
</Callout>

## Docker Compose

Each Pane release also ships a `compose.yaml` for running the relay with Docker. It pulls a container image that isn't public yet, so use `npx` for now.

## Good to know

- **Updating:** `npx --yes runpane@latest relay` always runs the latest release.
- **Certificates** renew on their own, with no restart.
- **Settings:** every `pane-relay` flag also reads an environment variable. `npx --yes runpane@latest relay --help` lists them all, including connection limits.
- **Many computers behind one office address?** Limits count each client address, so you may need a higher `--limit-agent-conns-per-min` and `--limit-new-ids-per-hour`.
- **Two name servers:** some registrars want two, and a second relay keeps your names working while one machine is down. The [full guide](https://github.com/greenfield-inc/Pane/blob/main/docs/SELF_HOSTED_RELAY.md) covers it, plus running from source.

## What your relay sees

The same as Pane's relays: which computer each connection is for, IP addresses, timing and byte counts. It can't decrypt traffic, because each computer ends the encryption with its own key. More in [Security, in plain words](/docs/remote-security).

## Related

- [How it connects](/docs/how-it-connects)
- [Use Pane on your phone](/docs/phone)
