brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tailscale netmap caching, and why my server cares about a coordination server outage

Tailscale netmap caching, and why my server cares about a coordination server outage

Tailscale published a post on 17 November about netmap caching, a client feature that saves a copy of your tailnet’s network map to disk. Many of my containers run on my tailnet through Unraid’s per-container Tailscale integration, so the question of what happens when Tailscale cannot reach its coordination server is not academic for me. Here is what the post says, in plain words.

What netmap caching does

Two things, according to Tailscale. Tailscale starts faster and reaches the other nodes in your tailnet faster, especially on bad connections. And it can connect to some or all of your nodes at startup even when the coordination server is unavailable.

It is opt-in for now. Tailscale says it needs an optional flag to activate at the time of writing, that it could become a default after successful testing, and that you manage it with your tailnet policy file, as described in the documentation. It is not available on Android and iOS yet, but it is planned.

Why a cache helps

To connect, nodes need three things from the internet: the coordination server, the DERP relay servers, and the other nodes if you want direct connections. The coordination server hands out keys, each node’s home DERP server and its endpoints. All of that together is the netmap, and every node gets its own version of it, because the access rules of your policy file are enforced through it. After the first full map the server only sends changes.

Without a cache, a node that restarts while the coordination server is unreachable has nothing to work with. With the cache on disk, it reads the saved map on start and can usually talk to other nodes through an encrypted WireGuard connection relayed over DERP. To limit wear on the disk, Tailscale only rewrites the chunks that changed, and the cache only holds nodes your policy lets you reach.

Who notices it first

Tailscale says the people who gain most are on slower and flakier networks, where getting a good connection to the coordination server and downloading the first map can take a while. With the cache, a minimal map is available straight away, and the latest information flows in once the connection to the coordination server is up. The post says this jump-start can make a big difference in startup time for end-user devices and servers alike.

That second group is the interesting one for a home server. A server does not have a person waiting at a login screen, so a slow start mostly shows up as a service that is unreachable for a minute after a reboot. If you run containers that have their own Tailscale identity, as many of mine do, every one of them has its own start-up to get through.

The clever part: direct connections

A relayed connection works but is not direct. Direct connections are negotiated by a protocol called DISCO, which uses short-lived keys. Every time Tailscale starts, it generates a new key pair, and normally the coordination server passes your new public key to the other side. If the coordination server is down, that does not happen, so no direct connection.

Tailscale’s trick is to send the new DISCO public key inside the already encrypted WireGuard tunnel over DERP, where the other device is listening for it. With that, direct connections can be set up again without the coordination server. Because a node may now hold several keys for a peer, learned in different ways, the client remembers more than one.

The limits

A node cannot stay online forever without the coordination server. As the tailnet changes, endpoints move, nodes get added or removed, policy and DNS change, and a cached map does not know about it. The post says plainly that the coordination server stays the central piece, so Tailscale gets more resilient against outages, but never independent of them.

One detail I like: if you change the policy file, it is still enforced as long as at least one node is connected to the control server, because policy is enforced on both ends of a connection. Established connections are not affected by gaps either, only new or changed nodes.

What I would do with it

On a server that restarts now and then, a quicker start and a way to reach other nodes when the internet is flaky sounds good. I would still treat it like any early opt-in feature: read the documentation first and turn it on for one node before anywhere else. I have not tried it, so I cannot tell you how it behaves in practice.

Tailscale also points to its post about making Tailscale faster for the speed side of this. If you run Tailscale on Unraid, watch for the day this becomes a default.

Further reading

Link