Install omnet Tailnet Lock on your Headscale server
omnet adds the server half of Tailnet Lock to Headscale. With Tailnet Lock, your own devices decide which new devices may join, not the server. A stolen join key or a taken-over server can no longer quietly add a device that everyone else trusts.
The Tailscale app on your devices already has the device half. It switches the Tailnet Lock
controls on only when the server says it supports them. Plain Headscale does not, so the app
greys them out. With omnet behind Headscale, the tailscale lock command works against your own
server (tested with the v1.102 command-line client on Linux; the graphical apps were not tested). Nothing new is installed on the devices.
This page gets you from nothing to a working lock. runbook.md is the careful,
step-by-step version for turning it on over a tailnet you already use, and it is rehearsed by a
test. The full engineering detail is in integration/headscale/README.md.
What you need
- A Linux ARM64 machine to build on (the Omega compiler makes AArch64 Linux programs).
- Go 1.26.5 or newer that may fetch toolchains (
GOTOOLCHAIN=auto); Headscale builds with Go 1.27.3. git, a POSIX shell, Python 3, and network access to the Go module proxy and to Headscale's source for the first build.- Headscale v0.29.6 (the patch is made for that exact release) and Tailscale clients at v1.102.x (the tested version; test others before you rely on them).
Build
From a checkout of this repository:
# The patched Headscale. Output: build/headscale
GO=/path/to/go sh integration/headscale/build.sh
# The Omega daemon that holds the lock's records. Output: build/tkad
# (The first run builds the pinned Omega compiler from its seed, so it is slow once.)
sh tools/build-tkad.sh
# Optional checks before you install anything:
GO=/path/to/go sh integration/headscale/leak-check.sh # the DERP memory fix (omnet#8) is in
sh tools/test.sh # every Omega unit suite
Try it on a throwaway tailnet first
Two tests run a complete private tailnet inside a fresh, empty network namespace with the stock Tailscale client. They never touch your real tailnet, its sockets or your network interfaces.
GO=/path/to/go sh integration/e2e/build-clients.sh
HEADSCALE_STOCK=1 HEADSCALE_OUTPUT=build/headscale-stock GO=/path/to/go sh integration/headscale/build.sh
sh integration/e2e/run.sh --sudo-netns # the lock's full lifecycle
sh integration/e2e/run.sh --sudo-netns --scenario runbook \
--stock-headscale "$PWD/build/headscale-stock" # runbook.md, step by step
Leave out --sudo-netns where your system lets ordinary users create user namespaces.
Run
tkad and Headscale run as the same user, in the same network namespace, tkad first.
build/tkad /var/lib/headscale/omnet --init # first start only: creates the state directory, then keeps running
build/tkad /var/lib/headscale/omnet # every later start (leave out --init)
OMNET_TKAD_SOCKET=/var/lib/headscale/omnet/tkad.sock \
OMNET_TKAD_ADMIN_USER_ID=<numeric Headscale user ID of the owner> \
build/headscale --config /etc/headscale/config.yaml serve
The owner is the Headscale user whose devices may start and switch off the lock. Pick the real
number from headscale users list; there is no default. Setting only one of the two variables is
an error.
Back up the Headscale database before the first start. The first start adds two columns and a
table. Stock Headscale then refuses that database until, on SQLite only,
integration/headscale/downgrade.sql has removed them
again (see the rollback in the runbook). There is no tested way back for PostgreSQL.
Turn the lock on
Devices that joined before omnet have no lock key on record. They keep working, but the lock will
not start (the server answers the owner's init with 409) until each of them has signed in once more, from its console or
a local-network session (see runbook.md step 3):
headscale preauthkeys create --user <ID of the device's own user> --expiration 1h # on the server
tailscale up --force-reauth --auth-key=file:<key file> --login-server=<URL> <its current settings> # on the device
Then, on one of the devices that will approve new devices:
tailscale lock # shows this device's key: tlpub:...
tailscale lock disablement-kdf <secret-hex> # turns each escape secret you made into its value
tailscale lock init --confirm --gen-disablements=0 disablement:<value1> disablement:<value2> tlpub:<A> tlpub:<B>
Type secrets and join keys only in a shell whose history is off (unset HISTFILE), and close it
afterwards. Make the escape secrets yourself beforehand (32 random bytes each, for example
head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n') and keep them somewhere safe that is not
the server. Give init only their disablement: values, never the secrets. From then on a new
device stays invisible to the others until an approving device runs tailscale lock sign.
tailscale lock disable disablement-secret:<secret> from an owner device switches the lock off
everywhere.
Before you rely on it
- Tested: the protocol and stock-client behaviour in an isolated tailnet (the lifecycle test and the runbook rehearsal, Linux command-line client v1.102.0), the Omega unit suites, and the DERP memory fix. Not tested: packet delivery, power loss, months of running, or a production security audit.
- tkad and Headscale share one user account. Whoever controls the server can read the daemon's state. Keep the approving keys on your devices and the escape secrets off the server, and keep a way into the server that does not depend on the tailnet (console, or SSH on the local network).
- The current daemon is sized for one tailnet of up to 64 devices and 128 lock changes. A change that would not fit is refused, never half-written.
- The patch is pinned to Headscale v0.29.6. Re-qualify it before you upgrade Headscale.