On-Premise Private Mesh

Headscale Private Network
Setup & Operations Guide

An end-to-end guide to fully eliminating dependence on the Tailscale SaaS cloud and the Tailworm security vulnerability, using a self-hosted open-source control server (Headscale) to connect 4 multi-OS machines over 100% encrypted P2P.

Connected machines
All 4
P2P latency
1 ~ 13 ms
Infrastructure control
100% On-Prem
Headscale Comic Overview
Captain Headscale the robot securely linking 4 devices over P2P 🛡️
Why Headscale?

Why a Headscale Private Network Instead of the Official SaaS?

4 key reasons: removing security risks and taking full control

⚠️ Fix 01

Block the Tailworm Vulnerability at the Source

Fully independent of the Tailscale SSH socket/port-forwarding privilege-escalation vulnerability (Tailworm) and the constraints of central SaaS authentication, you control 100% of your security policy directly on your own isolated control server.

⚡ Benefit 02

Ultra-Low-Latency Direct WireGuard P2P

The control server only coordinates the initial node key exchange; actual traffic flows directly between machines, encrypted with WireGuard. With no external relay server in the path, latency is just 1~13ms.

🌐 Tech 03

Working Around Cloudflare's Limits (ngrok Tunnel)

Cloudflare strips the WebSockets Upgrade header from Tailscale's POST /ts2021, causing 500 errors. An ngrok HTTPS tunnel, which passes WebSockets through intact, provides external connectivity without router port forwarding.

🔄 Convenience 04

Easy Multi-Profile Account Switching

Registered with --nickname headscale, with no need to reinstall the client, you can switch freely to and from your official account with the tailscale switch command or a single click in the tray menu.

Mesh Topology

Headscale P2P Network Topology

The central server only relays authentication; the 4 devices talk to each other directly in a full mesh.

flowchart LR subgraph ControlPlane ["🛡️ Control Plane (Linux martin-B650M-K)"] HS["Headscale v0.29.6\n(Port 8080 Docker)"] NG["ngrok HTTPS tunnel\n915f-211-112-160-46"] HS <-->|"Control Protocol"| NG end subgraph Mesh ["⚡ 100.64.0.0/10 WireGuard Direct Mesh"] MBP["💻 Hong's MacBook Pro\n100.64.0.1 (macOS)"] LNX["🐧 martin-B650M-K\n100.64.0.2 (Ubuntu)"] WIN["🖥️ NucBoxG3\n100.64.0.3 (Windows)"] MAC["🍎 hongsw's Mac mini\n100.64.0.4 (macOS, remote)"] end NG -.->|"Initial handshake"| MBP NG -.->|"Initial handshake"| WIN NG -.->|"Initial handshake"| MAC MBP <===>|"5 ms (P2P)"| LNX MBP <===>|"8 ms (P2P)"| WIN MBP <===>|"13 ms (P2P)"| MAC LNX <===>|"1 ms (LAN P2P)"| WIN
Performance Benchmark

Ultra-Low-Latency Verified: Real P2P Ping Comparison

High-speed direct connections up to 120x faster than external cloud VPNs

Measured network latency comparison (ms, lower is better)

Windows PC (local P2P)
1 ms
Direct link at gigabit-LAN speed
Linux server (local P2P)
5 ~ 7 ms
Instant SSH/DureClaw response
Remote Mac mini (P2P)
13 ms
Ultra-low latency even across the internet
Fleet Nodes

Live Status of the 4 Connected Nodes

All machines are online in the 100.64.0.0/10 range.

💻 Online

MacBook Pro

macOS (local workstation)

Headscale IP100.64.0.1
Node ID1
Direct PingReference node
🐧 Online

martin-B650M-K

Ubuntu 24.04 (Headscale host)

Headscale IP100.64.0.2
GPURTX 4090
Direct Ping5 ms
🖥️ Online

NucBoxG3

Windows 11 (mini PC)

Headscale IP100.64.0.3
Node ID3
Direct Ping1 ms
🍎 Online

hongsw's Mac mini

macOS (remote server)

Headscale IP100.64.0.4
Node ID4
Direct Ping13 ms
Cheatsheet

Essential Operations & Diagnostics Commands

Commands for status checks, P2P connectivity tests, and profile switching

📊 1. Check current network connection status
tailscale status
⚡ 2. Test direct P2P ping between machines
tailscale ping 100.64.0.2  # Linux server (5ms)
tailscale ping 100.64.0.3  # Windows PC (1ms)
tailscale ping 100.64.0.4  # Mac mini (13ms)
🖥️ 3. List all nodes on the Headscale server
# Run on the Linux host
docker exec headscale headscale nodes list
🔄 4. List and switch accounts
tailscale switch --list      # Show currently registered accounts
tailscale switch headscale   # Switch to the Headscale private network
FAQ & Lifecycle

Auth Key Expiry and How Permanent Registration Works

Why don't already-registered devices disconnect after the 90-day expiry?

🎟️ One-time ticket

The 4 Registered Devices = Kept Permanently

A pre-auth key is a one-time ticket that establishes trust with the server when a device is first registered.

On registration, the server and device permanently exchange an individual NodeKey, and under the server's Expiration: N/A (no expiry) policy the connection stays up permanently without re-authentication, even after 90 days.

🆕 Registering new devices later

What 90 Days Means = The Window for Registering New Devices

The auth key's 90-day validity means "the period during which new devices can be registered with this key."

Only when you later add a 5th PC or smartphone do you need to issue a new key on the server (it takes a second) and register it:

docker exec headscale headscale preauthkeys create --user 1 --reusable --expiration 90d