Homelab Network Fabric — 46 ms on the same switch

TailscaleHeadscaleWireGuardNixOSNetworkingTroubleshooting
Image 1
Image 2
Image 3
Image 4
Image 5

Slides (PDF)

The network

My devices share one private VPN (Tailscale). The control server that decides who is in it (Headscale) runs on my own VPS, not on a SaaS account.

What it's for:

  • Home from anywhere. With the VPN app on, my phone on mobile data (5G) opens home pages the same as on home Wi-Fi. Tested on 2026-10-22.
  • No admin access from outside. SSH and the router and server admin pages aren't on the public internet. Only web traffic and the VPN's own encrypted connections are open to the internet.
  • One login for most web apps. Most web apps reachable from the internet sit behind one passkey login (single sign-on).
  • A way back in. If the VPN or its control server breaks, a separate WireGuard tunnel still gets me into the server from home, so I can fix it.

To make the first part work, the home firewall offers the home network through the VPN. A device away from home takes that route and reaches home through the VPN.

The bug

On 2026-09-04, a ping between my laptop and a machine on the same switch went through a relay in Frankfurt, in 46 ms. Even the laptop's own router was 55 ms away. That was the tell: traffic to the router next to it was leaving through the VPN and coming back.

The laptop had taken the VPN's home route while sitting inside that same home network. The VPN's route wins over the normal one, so every neighbour on the LAN was answered through the VPN.

My config said no. But a toggle in the tray app or a re-login had turned it on, and that setting outlives every rebuild. It lives in Tailscale's own state, and nothing in a diff shows it.

The Windows PC had the same bug. 17–28 ms to the router next door. I fixed it by hand, and it went to 0.3 ms.

Why not turn the routes off for good?

Then the laptop can't reach home when I'm away.

The fix: the laptop decides by itself

Zoom
  • At home, the VPN's routes and its DNS go off. The home network is direct.
  • Away, both go on. Home goes through the VPN.
  • When it runs: on every network change, a minute after boot, and every hour.
  • It only corrects what drifted. It reads the live settings and changes them only when they're wrong, so a toggle flipped by hand is fixed on the next run.
  • No network isn't "away". With no network at all it changes nothing, so the laptop doesn't flip at every suspend.

My first version pinged the router to decide. It flapped every 30 seconds. Away from home the router answered too, through the VPN, so the ping said "home" everywhere. It now looks only at the laptop's own network connection.

Today

WhatState
My laptopDecides by itself on every network change and every hour
The Windows PCSame bug, fixed by hand: 17–28 ms → 0.3 ms
Phone on 5GOpens home pages the same as on home Wi-Fi
Control serverSelf-hosted on my VPS
If the VPN breaksA separate WireGuard tunnel still gets me into the server from home
ConfigDeclared once in my NixOS flake, a feature flag that a machine turns on

Stack

Tailscale, Headscale, WireGuard, NixOS, systemd, NetworkManager, passkey single sign-on.

Status

In daily use. The automatic switch runs on my laptop; the Windows PC keeps a setting I fixed by hand.

Related: my-nixos-infrastructure (the flake this is declared in) and my-homelab (what it reaches).