# Run edge servers apart from the nodes

> How to add two edge servers apart from the nodes, with floating IPv4 and IPv6 addresses. Also how to point the zone at both, reach a machine through each one, and check the egress of the machines.

The network redesign of 2026-10-27 changes this page. hopbox leaves the vRack and the OVHcloud API, and the servers talk over their public addresses (Q90). This page still describes the current code. Milestones N26 to N32 change the code and this page. Before you set up a fleet on the vRack, read Q90.

An edge server takes the public traffic of an install: the URL of each machine, SSH, the API, and the console. It also takes the egress of the machines to the internet ([the egress of the machines](/reference/egress/index.html.md)). A small install runs every role on one server. A bigger install runs the edge role and the DNS role on two servers of their own, `edge1` and `edge2`. The install then has two name servers. When one edge server stops, the other one takes the traffic. This guide adds two edge servers to an install whose servers talk over their peer addresses. Then it reaches a machine through each edge server.

An edge server without the node role reaches each machine over the mesh, the WireGuard device `hbm0` between the servers ([the mesh](/reference/mesh/index.html.md)). [The edge role](/reference/edge/index.html.md#the-way-to-the-machines) covers the way to the machines in full.

The release files of hopbox are not public yet. The hopbox team gives them on request.

## How a client reaches a machine

1. The client asks DNS for `box1.example.com`. Each edge server answers with the DNS role. The zone names the floating IPv4 address of each edge server, and its floating IPv6 address. `ns1` is `edge1`, and `ns2` is `edge2`.
2. The client connects to one of the addresses. It uses HTTPS for a machine URL or the API, and SSH for the SSH port of the machine.
3. The edge server finds the node of the machine in its routes. It connects to the address of the machine over `hbm0`, from its mesh address.
4. The node lets the connection reach the machine, because the mesh address belongs to an edge server.

A floating address is a public IPv4 address that the provider of the servers can route to one server and then to another. Examples are an Additional IP of OVHcloud, and a floating IP of another provider. The operator routes it to the edge server at the provider. A replacement of the edge server takes the same address, so the zone never changes. The floating IPv6 address of an edge server is an IPv6 address that the operator routes to the edge server at the provider. The edge server holds it on its uplink as a `/128`. `hopboxd` does not put it there ([the edge role](/reference/edge/index.html.md#the-public-ipv6-address)). The IPv6 egress of the machines leaves from another address: the IPv6 address of the uplink.

## What you need

- An install with a control server that listens on its peer address, and nodes in the mesh ([the mesh](/reference/mesh/index.html.md#which-servers-join)).
- Two servers for `edge1` and `edge2`.
- One floating IPv4 address for each edge server. This guide uses `203.0.113.101` for `edge1` and `203.0.113.102` for `edge2`. The operator routes each address to its edge server at the provider. The edge server holds it on its uplink as a `/32`, and the peer address stays the source of its default route. So the connections of the edge server to the other servers leave from its peer address. The Terraform provider sets this up with the attribute `floating_addresses` ([hopbox Terraform provider](/reference/terraform-provider/index.html.md#the-network-setup-of-an-edge-server)). Without the provider, set it up by hand.
- One floating IPv6 address for each edge server, held on its uplink as a `/128`. This guide uses `2001:db8::11` for `edge1` and `2001:db8::12` for `edge2`. The Terraform provider sets this up with the attribute `public_ipv6`.
- An IPv6 default route and a global IPv6 address on the uplink of each edge server, for the IPv6 egress of the machines. This guide uses `2001:db8:1::21` for `edge1` and `2001:db8:2::22` for `edge2`.
- The internal URL of the control server on its peer address, such as `https://203.0.113.11:7443` ([the internal listener](/reference/internal-listener/index.html.md)).
- The peer address of each server: its public IPv4 address on its uplink, at which the other servers reach it ([Enrollment and the install PKI](/reference/enrollment/index.html.md#peer-addresses)). This guide uses `203.0.113.21` for `edge1`, `203.0.113.22` for `edge2`, and `203.0.113.31` for the node `node1`.
- `dig`, `curl`, and `ssh` on your laptop.

## Add the edge servers

### Write the bootstrap config of each edge server

On `edge1`, write `/etc/hopbox/hopboxd.toml` before the install. The install keeps the keys of the file ([hopboxd](/reference/hopboxd/index.html.md#install)):

```toml
roles = ["edge", "dns"]

[dns]
listen = ["203.0.113.101:53", "[2001:db8::11]:53"]

[edge]
public_ipv6 = "2001:db8::11"
public_ipv4 = "203.0.113.101"
```

On `edge2`, write the same file with `203.0.113.102` and `2001:db8::12`.

The tested OS runs `systemd-resolved` on port 53 of a loopback address. So `dns.listen` names the public addresses of the server, not every address ([the DNS role](/reference/dns/index.html.md#listeners)). The DNS role takes queries on the floating IPv6 address once the uplink holds it. `edge.public_ipv6` names that address, without a prefix length ([the bootstrap config of hopboxd](/reference/hopboxd-config/index.html.md#keys)). `edge.public_ipv4` names the floating address from which the egress of the machines leaves. The Terraform provider writes these keys for you ([hopbox Terraform provider](/reference/terraform-provider/index.html.md#edge-servers-and-floating-addresses)).

### Install and enroll each edge server

On the control server, make a token for each edge server. The token names the peer address of the edge server, so the enrollment must come from that address, and the server keeps it:

```sh
sudo hopboxd admin enrollment-token create --roles edge,dns --peer-address 203.0.113.21
```

On `edge1`, install with the URL of the control server, and enroll with the token:

```sh
sudo hopboxd install --roles edge,dns --control-url https://203.0.113.11:7443
sudo hopboxd enroll --token <token>
```

Do the same on `edge2` with its own token, for the peer address `203.0.113.22`.

### Reach the servers through the edge servers

On its public interface, the host firewall of each server takes the mesh port and the ports of the egress tunnels only from the peer addresses of the install ([the host firewall](/reference/host-firewall/index.html.md#sets)). Port 22 of a server without the edge role takes only the peer addresses of the edge servers, the set `jump_hosts`.

Each edge server got its peer address from its token. A server that enrolled without a peer address, such as a server from before peer addresses, has no part in these sets. On the control server, set its peer address. For example, for `node1`:

```sh
sudo hopboxd admin server set-peer-address <id of node1> 203.0.113.31
```

Within 5 s, each server holds the peer addresses of the edge servers in the set `jump_hosts` of its table:

```sh
sudo nft list set inet hopbox_host jump_hosts
```

From your laptop, port 22 of `node1` times out. Log in to `node1` through `edge1` as the jump host, at the peer address of `node1`. `edge1` dials `node1` from its peer address, the source of its default route:

```sh
nc -vz -w 3 203.0.113.31 22
ssh -J debian@203.0.113.101 debian@203.0.113.31
```

`node1` keeps these jump hosts, also when the edge servers leave the install. The way back after a lockout is the rescue mode or the console of the provider ([the host firewall](/reference/host-firewall/index.html.md#never-a-lockout)).

### Check the mesh and the IPv6 address

On the control server, list the servers. Each edge server is `ready`:

```sh
sudo hopboxd admin server list
```

`hopboxd admin server get <id>` shows the mesh address of each edge server in `mesh_address` ([hopboxd](/reference/hopboxd/index.html.md#admin-server-get)).

On `edge1`, check the floating IPv6 address and the IPv6 default route of the uplink:

```sh
ip -6 addr show to 2001:db8::11
ip -6 route show default
```

The uplink holds `2001:db8::11`, and the IPv6 default route names the uplink. The log of `hopboxd` shows the line `the IPv6 egress of the machines leaves from the uplink address of this edge server`, with the uplink and `2001:db8:1::21` ([the host firewall](/reference/host-firewall/index.html.md#the-uplink-and-the-nat66)).

## Point the zone at both edge servers

### Set the public addresses

The zone names the public addresses of the install. `ns1` takes the first address of each family, and `ns2` the second ([the DNS role](/reference/dns/index.html.md#the-zone-of-the-install)). So list `edge1` first:

```sh
sudo hopboxd admin config set --public-address 203.0.113.101,203.0.113.102,2001:db8::11,2001:db8::12
```

### Check each name server

Ask each edge server at each of its addresses. Each answer has the flag `aa`, and names both edge servers:

```sh
dig @203.0.113.101 box1.example.com A +norec
dig @2001:db8::12 box1.example.com AAAA +norec
dig @203.0.113.102 example.com NS +norec
```

The `NS` answer names `ns1.example.com` and `ns2.example.com`. Its additional section gives `ns1` the addresses of `edge1`, and `ns2` the addresses of `edge2`.

Each heartbeat of an edge server reports the serial of the zone that it serves. Both edge servers report the same serial:

```console
$ sudo hopboxd admin server get <id of edge1> | grep dns_zone_serial
dns_zone_serial	1792249094
```

### Delegate the domain

Give the parent zone the two name servers and their glue records: `ns1` at the addresses of `edge1`, and `ns2` at the addresses of `edge2` ([Serve the domain of an install with the DNS role](/guide/dns-role/index.html.md#make-the-records-in-the-parent-zone)). If the domain points at another server now, change the glue records last. A resolver keeps an answer for 60 seconds.

## Reach a machine through each edge server

The certificate of the install reaches both edge servers over the control channel ([Get the wildcard certificate of an install](/guide/acme-certificate/index.html.md)). Open the URL of `box1` through each edge server. `--resolve` sends the request to one address:

```sh
curl --resolve box1.example.com:443:203.0.113.101 https://box1.example.com/
curl --resolve 'box1.example.com:443:[2001:db8::12]' https://box1.example.com/
```

Open SSH through each edge server, at the SSH port of `box1`, such as 10022 ([Reach a machine over SSH](/guide/ssh/index.html.md)):

```sh
ssh -p 10022 user@203.0.113.101
ssh -p 10022 user@2001:db8::12
```

The code of the machine sees the mesh address of the edge server as the client, such as `10.239.0.3`. The header `X-Forwarded-For` of a request holds the address of the real client ([the edge role](/reference/edge/index.html.md#what-a-machine-gets)).

## Check the egress of the machines

Each node sends the egress of its machines through an egress tunnel to one edge server. The hash of the machine address picks the edge server ([the egress of the machines](/reference/egress/index.html.md#the-hash-of-a-machine)). On `edge1`, check its tunnel, and the routes of the replies back into it:

```sh
sudo wg show hbe0 allowed-ips
ip rule show table 26819
sudo nft list chain inet hopbox_host egress_nat
```

The tunnel has each node as a peer, with its subnet and the IPv6 `/64` of that subnet. The rule `fwmark 0x68620100 lookup 26819` sends the replies back into the tunnel. The chain `egress_nat` gives the IPv6 egress of the machines the address of the uplink, `2001:db8:1::21` (NAT66).

In a machine, ask a server on the internet for the address that it sees:

```sh
hopbox exec box1 curl -sS https://ifconfig.me
hopbox exec box1 curl -6 -sS https://ifconfig.me
```

The commands print the floating IPv4 address and the IPv6 address of the uplink of one edge server, such as `203.0.113.101` and `2001:db8:1::21`. The IPv6 egress never leaves from the floating IPv6 address. Both families of one machine leave through the same edge server. An edge server without `edge.public_ipv4` gives the IPv4 egress the address of its uplink, and logs a warning at its start. An edge server without a global IPv6 address on its uplink refuses the IPv6 egress, and logs a warning.

## When an edge server stops

The other edge server goes on: it answers DNS, the machine URLs, SSH, and the API. A resolver that gets no answer from one name server asks the other one. The control role marks the stopped edge server `unresponsive` after 20 s. At their next heartbeat, the nodes then send all the egress of their machines to the other edge server. The address of the stopped edge server gives no answer to a client. It answers again when the edge server is back, or when its replacement takes the address.

A DNS server keeps the last zones of the control plane on its disk ([the DNS role](/reference/dns/index.html.md#zones-on-the-disk)). So an edge server that restarts while no control server runs answers with those zones. Its log shows `serving the dns zones on the disk until the control plane sends its zones`.

## Replace an edge server

The new server takes the same addresses as the old one:

1. Write the bootstrap configuration of the new server with the same `edge.public_ipv6` and `edge.public_ipv4`. Put the floating IPv4 address on its uplink as a `/32`, and the floating IPv6 address as a `/128`. The Terraform provider does this step with `floating_addresses` and `public_ipv6`.
2. Install and enroll the new server as above, with a token for its own peer address. The servers of the install then take SSH from the new server as a jump host.
3. Route the floating IPv4 address and the floating IPv6 address to the new server at the provider. The Terraform provider never moves an address.

The public addresses of the install stay the same, so the zone and the glue records need no change. The IPv6 egress of the machines leaves from the uplink address of the new server, so its IPv6 source changes ([the egress of the machines](/reference/egress/index.html.md#the-source-addresses)).

## Take the edge role from a server

A server can give its roles edge and DNS to the edge servers and keep its other roles ([the admin API](/reference/admin-api/index.html.md#removeserverroles)). An example is a first server that keeps the roles control and node. This section takes them from the server `server1`, while the edge servers keep them.

1. Make sure that another edge server is ready with the roles edge and DNS, and holds a floating address. The removal checks it.
2. Set the public addresses of the install without the addresses of `server1`. Then the zone names only the edge servers that stay. Run on a control server:

   ```sh
   sudo hopboxd admin config set --public-address 203.0.113.101
   ```

3. Wait until each name server serves the new zone, as in [Check each name server](#check-each-name-server). The parent zone keeps its glue records only for the name servers that stay.
4. Start the removal. Run on a control server:

   ```sh
   sudo hopboxd admin server remove-role <id of server1> edge dns
   ```

5. If `server1` is a control server whose internal listener listens on loopback, move the listener to the peer address of `server1`. The control role refuses a token with a peer address on a call from loopback, and in step 6 `server1` calls its own listener. Run on `server1`, with every role that it has now ([the internal listener](/reference/internal-listener/index.html.md#move-the-first-server-to-its-peer-address)):

   ```sh
   sudo hopboxd install --roles control,node,dns,edge --internal-listen <peer address of server1>:7443
   ```

6. End the removal on `server1`. Make a token for the server and the roles that stay, and run the install with every role that stays:

   ```sh
   sudo hopboxd admin enrollment-token create --server <id of server1> --roles node --peer-address <peer address of server1>
   sudo HOPBOX_ENROLLMENT_TOKEN=<token> hopboxd install --roles control,node
   ```

7. After the restart of `hopboxd`, remove the floating addresses of `server1` from its uplink. The uplink is the interface of the IPv4 default route, which `ip route show default` names after `dev`. This example uses `eth0`, the floating IPv4 address `203.0.113.100`, and the floating IPv6 address `2001:db8::10`. Run on `server1`:

   ```sh
   sudo ip address del 203.0.113.100/32 dev eth0
   sudo ip address del 2001:db8::10/128 dev eth0
   ```

   Then remove the addresses from the network configuration of the host too, so that a reboot does not put them back.

`hopboxd` restarts without the roles edge and DNS, and the services of `server1` stop for some seconds. Its host firewall closes ports 80, 443, 53, and the SSH ports of the machines. From then on, port 22 takes only the jump hosts. So reach `server1` through an edge server that stays ([Reach the servers through the edge servers](#reach-the-servers-through-the-edge-servers)). For a server that Terraform manages, drop the roles `edge` and `dns` from its configuration, and apply instead. Drop its floating addresses there too. The provider runs steps 4 to 7 ([hopbox Terraform provider](/reference/terraform-provider/index.html.md#roles-of-a-running-server)).
