Headscale: A Self-Hosted Alternative to Tailscale with Installation and Use Cases

TL;DR

An in-depth look at Headscale — a self-hosted alternative to Tailscale. We break down its architecture, installation via Docker and systemd, configuration of OIDC and ACL, DERP and routing, plus 7 practical use cases with measurable results, tips, and comparisons with alternatives.

Headscale: A Self-Hosted Alternative to Tailscale with Installation and Use Cases

Introduction: Why You Need Self-Hosted Headscale and the Problem It Solves

We live in a world of distributed teams, hybrid infrastructure, and multiple environments — from home servers to cloud clusters across regions. In this reality, traditional VPNs don’t solve all challenges. What you need is a private, self-configuring network over the internet that's easy to connect, resilient, and scalable. That’s exactly what WireGuard-based mesh solutions offer, and one of the most user-friendly is Tailscale. But Tailscale is a SaaS control plane. If your security, compliance, or budget requirements mean you want to keep control in-house, you need a self-hosted option. Enter Headscale — an open-source control plane compatible with Tailscale clients.

Headscale addresses three key issues: you store metadata and access keys yourself; you can configure what’s limited in SaaS; and you get predictable costs without dependency on external providers. Alongside this, you get a private WireGuard network with end-to-end encryption, automatic NAT traversal, and easy device onboarding.

Headscale Service Overview: Features, Architecture, and Benefits

What is Headscale? It’s a self-hosted control plane compatible with Tailscale client management protocols. Data flows over WireGuard, keys are generated on devices, and control messages go through your Headscale server. You manage users, ACL policies, routes, MagicDNS, and, if needed, your own DERP relays. Headscale is written in Go, and a typical install is a single binary or container plus a database.

Architecture. Three layers: 1) tailscaled clients on nodes (Linux, Windows, macOS, FreeBSD, containers, and VMs), 2) your Headscale control plane with storage (SQLite or a relational DBMS), 3) DERP servers for relaying traffic behind complex NATs. By default, clients form direct WireGuard peers; if that’s not possible, traffic goes through DERP. The control plane doesn’t carry user traffic—it issues peer coordinates and keys.

Functionality (relevant for production in 2026):

  • Compatible with the latest Tailscale clients on desktop and server platforms.
  • Users and groups, service node tags, preconfigured connection keys (preauth keys), and short-lived (ephemeral) keys for contractors.
  • ACL policies with an explicit allow model, rules by user, groups, tags, ports, and protocols. Support for tag-based policies on headless nodes.
  • Subnet routes (subnet routers), external network announcements, exit nodes to route all internet traffic through trusted nodes.
  • MagicDNS for stable host and service names inside the private network.
  • OIDC authentication with corporate SSO, user claims, and automatic account creation.
  • DERP integration: use public relays or run your own to reduce latency and external dependencies.
  • Prometheus metrics and logging for audit and observability.

Benefits. The most important are control and isolation. You manage key lifecycles and policies, keep metadata locally, and costs don’t grow linearly with node count (especially scaling to hundreds or thousands). WireGuard performance is high: modern x86-64 hardware can easily hit hundreds of Mbps or more, with latency often close to standard internet routes. Headscale integrates well with DevOps tools and IaC to quickly onboard sites and migrate between clouds without friction.

Use Case 1. Homelab Without Open Ports: Private Access to NAS, Cameras, and Services

Who It’s For and Why

Engineers, DevOps pros, and enthusiasts running home clusters: NAS, mini-PCs with containers, media servers, smart homes. The goal is access from work or travel without port forwarding or public IPs, with encryption and friendly hostnames.

How It Works

You deploy Headscale on a VPS or a small home server and register devices with preauth keys. Each node runs tailscaled which builds WireGuard tunnels to peers using private addresses. MagicDNS provides stable names; ACL blocks unwanted directions.

Step-by-Step Instructions

  1. Prepare a server with TCP and UDP public accessibility and synchronized NTP system clock. Install Headscale as a container or via package manager. Start with SQLite and switch to a relational DB later if needed.
  2. Enable TLS termination via reverse proxy. The simplest home setup uses automatic certificate provisioning. Proxy Headscale on a local address and port.
  3. Create your first Headscale user (your domain admin). Then generate reusable or one-time preauth keys for each device.
  4. Install the Tailscale client on nodes. Start tailscaled and connect the node using login server address and preauth key. Use tags for headless servers, e.g., tag:home-lab.
  5. Enable MagicDNS and verify hostname resolution. Create a simple ACL: from your laptop to NAS and media server access, not vice versa.
  6. If needed, set up a local DERP relay near home if some devices are behind symmetric NAT and cannot form direct peers.

Example and Results

Case: N100 mini-PC with Docker, NAS, and Home Assistant. Before Headscale, external access required port forwarding and DDNS. After implementation: connecting to media server and Git runners from a mobile laptop works without open ports. Typical latency between the laptop on mobile network and home node dropped from 65–80 ms to 40–55 ms thanks to direct WireGuard. SMB file copy speeds rose from 12–20 to 80–140 Mbps depending on mobile network and router.

Tips and Best Practices

  • Assign static host and service names via MagicDNS using short aliases.
  • Enable logging on Headscale and export metrics to Prometheus for visibility.
  • For energy-efficient SoCs, limit MTU on WireGuard interface to minimize fragmentation.
  • If one node frequently acts as relay, assign it a dedicated channel or set up a local DERP to reduce load.

Use Case 2. Team Access to Staging and CI/CD Artifacts Across Clouds

Who It’s For and Why

Product and platform teams with staging environments spread across providers and regions, where Git runners build containers in one cloud and push images to another. The aim is to free developers from individual SSH keys, simplify service access, and hide infrastructure from the public internet.

How It Works

Deploy Headscale in a separate subnet, register build clusters, staging, and developer laptops. Inter-service traffic flows over private addresses allowed by ACL. Tags are applied on runners and service nodes to avoid creating user keys. Secrets for container registries remain within the private network.

Step-by-Step Instructions

  1. Deploy Headscale and configure OIDC with your corporate SSO provider. This enables automatic user creation and access revocation on exit.
  2. Create groups for teams (e.g. devs, qa) and tags for services (tag:runner, tag:staging). Enforce default-deny policy.
  3. Register Git runners and staging VMs with tags. Provide users with preconfigured keys or allow SSO login.
  4. Define ACL: developers -> staging on required ports, runners -> registry, artifact cache -> runners and staging, no public internet.
  5. Add a subnet router for legacy bare-metal services, letting staging access them without opening perimeter.

Example and Results

A company with 45 developers and 12 runners across two regions. Previously relied on SSH bastions, open security groups, and frequent "forgotten" key incidents. After move to Headscale: new developer onboarding takes 10 minutes (SSO + policy), access time to staging reduced from hours of approval to minutes. External open ports cut from 38 to 6. Inter-region egress traffic dropped 28% thanks to direct peering tunnels.

Tips and Best Practices

  • Use ephemeral keys for temporary contractors lasting 8–24 hours with renewal on ticket request.
  • Assign tags only to headless nodes to simplify rotation and auditing without user bindings.
  • Store artifact-server and registry addresses as MagicDNS names in CI. This survives any IP migration.

Use Case 3. Connecting a Closed Industrial Network (OT) via Subnet Router with Access Control

Who It’s For and Why

Integrators and automation engineers with PLCs, HMIs, and network gear lacking modern remote access. Goal: Provide limited access to engineers for diagnostics and updates while keeping the network isolated from the internet.

How It Works

Install tailscaled on an OT gateway node and enable subnet route announcement. Engineers connect via Headscale, access only allowed ports (e.g. Modbus/TCP, HTTPS admin panel), rest blocked by ACL. One-way access allowed to prevent inbound connections to engineers’ laptops.

Step-by-Step Instructions

  1. Set up a gateway node at OT boundary with two interfaces: one to the OT network, the other to IT network/internet.
  2. Install Tailscale client and register node in Headscale with tag tag:ot-gateway. Enable route announcement for OT subnet (e.g. 10.10.0.0/16).
  3. Activate this route in Headscale. Create ACL 'engineers -> tag:ot-gateway -> 10.10.0.0/16 tcp:443,502' (example ports). Block reverse access.
  4. Enable access logging and audit via SIEM, collect metrics.

Example and Results

Remote mining site monitoring project: 3 gateways, 17 PLCs, 4 HMI panels. Previously used costly L2VPN channels. After switching to Headscale with subnet router, channel cost reduced by 42%, MTTR dropped from 2 hours to 25 minutes thanks to standard remote engineer access. Packet inspection on gateway; tunnels encrypted end-to-end.

Tips and Best Practices

  • Strictly limit ports, forbid RDP/SSH in OT, grant engineers only needed access.
  • Enable audit logging, keep records for at least 90 days.
  • For sensitive sites, deploy local DERP on premises to prevent traffic leaving country/region.

Use Case 4. Hybrid: Connect On-Prem Database and Cloud Kubernetes Without Public Internet

Who It’s For and Why

Teams migrating services to Kubernetes but keeping databases and message queues on-prem. Goal: Simplify network connectivity without IPsec or complex routing, enable fast rollback and cloud migrations.

How It Works

Give tailscaled to each cluster node (or gateway pod). Announce the database via subnet router or run a node inside the DB network. Kubernetes apps access the DB using a MagicDNS name. ACL restricts access to only required namespaces and ports (5432, 27017, etc.).

Step-by-Step Instructions

  1. Create a sidecar or DaemonSet image with tailscaled for nodes/pods needing outbound private access, or use node-level tailscaled on workers.
  2. Register these nodes in Headscale with tag: tag:k8s. For the DB, run a node with tag: tag:db.
  3. Configure ACL: tag:k8s -> tag:db on tcp:5432 and other required ports, deny others.
  4. Assign MagicDNS name to the database and use it in manifest environment variables.
  5. For high availability, enable two DERP relays in different regions and test failover.

Example and Results

Fintech startup: Kubernetes in two regions, on-prem DB in a data center with extended support. Previously used complex IPsec tunnels with frequent interruptions during key rotation. After Headscale migration: new environment deploys in 15 minutes, regional failure doesn’t affect connectivity. Average DB read latency through tunnel is 6–8 ms, write 8–12 ms; SLA over 99.95% without manual intervention.

Tips and Best Practices

  • Plan MTU carefully: Kubernetes CNI plus WireGuard add overhead; test to find optimal value.
  • Run tailscaled in a dedicated low-priority cgroup so it doesn’t compete with workloads.
  • Use read replicas for cross-region requests so latency-sensitive operations run locally.

Use Case 5. Exit Node for Remote Employees with Policies and Secure Internet

Who It’s For and Why

Companies with traveling employees connecting from insecure networks. Goal: Provide internet via corporate node with filtering and monitoring, without exposing internal services publicly.

How It Works

Set up a dedicated exit node server, enable forwarding and NAT. Allow employees to use this node for internet egress. ACL and policies restrict who may use the exit node. Logs and content filtering remain under corporate control.

Step-by-Step Instructions

  1. Deploy server with solid bandwidth and CPU. Enable IPv4/IPv6 forwarding and firewall NAT rules.
  2. Register node in Headscale with tag: tag:exit, enable exit node mode on client.
  3. Grant exit access in ACL to traveler group; deny to others.
  4. Deploy DNS and web traffic filtering on exit server, connect metrics.

Example and Results

Outsourced team of 20 frequent flyers. Previously used public Wi-Fi risking interception. After exit node deployment, all staff traffic routed through corporate node, enabling unified security policies and logging incidents. Added latency of 15–25 ms compared to direct regional internet.

Tips and Best Practices

  • Plan two exit nodes: one in a "far" region and one nearby. Select geographically close for lower latency.
  • Enable end-to-end DNS with MagicDNS and centralize malicious domain blocking policies.
  • Keep exit node and critical business services separate for predictable operation.

Use Case 6. Managing IoT and Camera Fleets at Remote Sites

Who It’s For and Why

System integrators and companies with many edge devices — cameras, sensors, gateways. Goal: access devices for diagnostics and updates without port forwarding or SIM-APN tricks, with clear tracking and auditing.

How It Works

Each site gateway runs a low-cost tailscaled instance. It announces subnets hosting devices or acts as a proxy. Control servers and engineers connect to Headscale centrally. ACL defines communication: engineer -> gateway -> devices. Ephemeral keys can enable temporary access windows.

Step-by-Step Instructions

  1. Standardize gateway image: tailscaled plus system agents, basic firewall, and monitoring. Close SSH from outside.
  2. Deploy Headscale, create tags tag:edge-gw and engineer groups.
  3. Add routes to local device subnets and enable them in the Headscale dashboard.
  4. Define ACL: engineers -> tag:edge-gw -> device ports for control and streaming.
  5. Set up metric collection, access log aggregation, and new node connection alerts.

Example and Results

Retailer with 120 stores, 8–12 cameras each. Previously used tunnels on consumer routers, unstable and hard to support. After migrating: uptime measured at 98.7%, average latency to central office 18–32 ms, new store deployment under 30 minutes with ready gateway image. Incidents with strange outgoing connections disappeared as engineers initiate all access via private addresses.

Tips and Best Practices

  • Enable watchdog and auto-restart for tailscaled on gateway nodes after network faults.
  • Generate preauth keys in batches with 48–72 hour lifetime for distribution and installation.
  • Deploy local DERP servers in key regions to avoid tunnels searching far relays for large video streams.

Use Case 7. Temporary Access for Contractors and Auditors: Ephemeral Keys, Tags, Approval

Who It’s For and Why

Teams requiring frequent access for external specialists on limited terms. Goal: grant exactly the access needed and automatically revoke it when work is done without manual key cleanup.

How It Works

Create ephemeral preauth keys or set expiration on regular keys, assign tags and ACLs to target only necessary services. After expiration, nodes vanish from the network cleanly. Optionally enforce approval workflows before route activation.

Step-by-Step Instructions

  1. Create a contractors group and tags tag:readonly, tag:reveng.
  2. Generate preauth keys with 24–72 hour expiration, make them one-time use.
  3. Define ACLs only for essential services, e.g., test environment web UI and artifact repository.
  4. Monitor node appearances in logs; enable manual approvals if needed.

Example and Results

A 10-day security audit. Contractor was given staging and log copy access. Nodes automatically removed after expiration. Reissuing access for a repeat audit took 15 minutes. No incidents with forgotten keys.

Tips and Best Practices

  • Tag these nodes clearly and prefix names for easy identification.
  • Don’t grant exit node rights to contractors unless essential.
  • Set up warnings for impending key expiration to avoid unexpected downtime during work windows.

Headscale Installation and Basic Setup: From Zero to First Node

Preparing the Environment

  • Linux server with public TCP/UDP accessibility. System clock synchronized via NTP.
  • Dedicated domain name for convenience. TLS termination through reverse proxy.
  • Open outbound connections for clients (UDP for NAT traversal).

Deployment

  1. Install Headscale as a container. Create a compose file with headscale and optional DB. Map internal Headscale port to localhost, offload TLS to reverse proxy. Set variables for domain name, MagicDNS mode, SSO provider (if used).
  2. Start Headscale, ensure service responds and logs properly. Check Prometheus metrics if enabled.
  3. Create first user (e.g. admin). Generate preauth key. Configure OIDC: specify provider URL, app ID, secret, and map email domains to groups.
  4. Optionally deploy DERP relay in the same infrastructure. Record its coordinates in Headscale config and test access from two networks.

Connecting the First Node

  1. Install Tailscale client on server or laptop. Start the system service.
  2. Connect to your control plane by specifying login server address and preauth key. Add flags for tags or route announcements as needed.
  3. Check status, peer list, and MagicDNS resolution. Ping nodes to confirm end-to-end connectivity.

ACL and Routes

  • Create a minimal policy: default deny, then granular allows by groups and tags.
  • Enable subnet route announcement on the node with access, allow routes in Headscale. Verify forwarding and firewall rules.
  • For exit nodes, enable system forwarding and NAT; restrict exit access by group.

Common Mistakes and How to Avoid Them

  • Missing NTP: desync over a few minutes breaks WireGuard handshakes. Monitor clock synchronization carefully.
  • Blocked UDP: firewalls or ISPs blocking UDP cause peers to rely on DERP. Check UDP pass-through and add local DERP relays near nodes.
  • Incorrect MTU: causes fragmentation and TCP issues. Debug with traces and reduce MTU by 40–80 bytes if needed.
  • Overly broad ACLs: follow least privilege—limit ports and directions precisely.
  • Long-lived reusable preauth keys: use expiry and single-use keys especially for external users.

Performance and Stability: What to Expect and How to Measure

Speed. On modern x86 with crypto acceleration, you can easily get 600–900 Mbps of throughput between data centers on direct peerings. Energy-efficient SoCs (N100, N5105) achieve 300–600 Mbps with proper MTU. Mid-range ARM devices typically do 100–300 Mbps. DERP reduces throughput depending on relay resource and geography.

Latency. Direct peering latency often matches internet routes: 2–10 ms regionally, 20–40 ms inter-regionally. Through DERP add 10–40 ms extra to relay path. Hosting your own DERP in the region can cut that penalty by 25–60% compared to remote relays.

Reliability. Typically, 90–95% of peers connect directly, others use DERP. Symmetric NAT and CGNAT require planning for relays. Monitoring metrics (direct/DERP peer counts, handshake errors, jitter) helps react quickly.

Integrations and Automation: Embedding Headscale into Your Existing Stack

  • Reverse-proxy: use Caddy or Traefik for automated TLS and easy routing. Expose Headscale only via internal ports behind proxy.
  • IaC: keep Headscale configuration (users, ACLs, tags) in Git. Apply changes through pipelines with PR reviews.
  • Ansible: roles for installing tailscaled on nodes, issuing preauth keys, and enabling routes. Great for mass onboarding.
  • Monitoring: collect Headscale metrics in Prometheus, visualize with Grafana. Set alerts on DERP peer counts, SSO auth failures, routing errors.
  • Logs: centralize with Elastic-stack or similar, configure retention and searchable events for node joins/leaves and errors.

Comparison with Alternatives: Where Headscale Excels and What to Watch For

Headscale vs Tailscale (SaaS)

  • Data Control and Storage: Headscale keeps metadata locally, easing internal compliance. Tailscale cloud handles part of management externally.
  • Flexibility: run your own DERP, integrations, and any non-standard configurations fitting your policies.
  • Cost: Headscale scales predictably; you pay for infrastructure instead of per-node licenses.
  • Feature Support: most core functions are supported, but some proprietary cloud features may be missing or differ. Check current lists when planning migration.

Headscale vs ZeroTier

  • Both are mesh networks. Headscale is based on WireGuard and compatible with Tailscale clients; ZeroTier uses its own stack.
  • Headscale offers a simpler OS-level model and tight integration with Linux network tools. ZeroTier suits L2/L3 hybrid and virtual switches.
  • WireGuard often outperforms in CPU-accelerated encryption speed.

Headscale vs Netmaker/Netbird

  • Netmaker and Netbird are WireGuard orchestrators with rich UIs. Headscale excels with mature ACL and routing models compatible with Tailscale clients but may require third-party dashboards.
  • If you're already in the Tailscale client ecosystem and want self-hosting, Headscale is often the natural choice.

Headscale vs Classic VPNs (OpenVPN/IKEv2)

  • Mesh with NAT traversal is simpler to onboard and handles unstable networks better. MagicDNS and tags provide flexible access control.
  • Classic VPNs are needed for static internet exit, bypassing restrictions, or single-gateway setups with fixed IPs for specific tasks.

Expert Note on Classic VPN Use Cases

If you need a personal static IP, international banking access, censorship circumvention, or selecting protocols optimized for your provider, that’s a different niche, not a replacement of mesh networks. A practical solution is a personal VPN server like vpn.how: dedicated IP per client, multiple protocols (WireGuard, OpenVPN, IKEv2, L2TP, SSTP) customizable by network, server locations in key cities (Moscow, St. Petersburg, Amsterdam, Frankfurt, London, New York, San Jose, Chicago, Singapore, Sydney, Madrid, Helsinki, Stockholm, Warsaw, Copenhagen, Stavanger), convenient payment methods (including Russian bank cards, instant payment system, and crypto), plans from 490 ₽/day and 2490 ₽/month with discounts, quick 5-minute setup, and no logs. This service complements Headscale: it covers privacy and internet exit under your IP, while Headscale handles internal node networking and service access.

FAQ: Common Practical Questions

1. Can mobile clients be used?

Desktop and server clients work smoothly. Mobile official clients vary their support for custom login servers. In production, teams often rely on laptops and gateways; for mobiles, local proxies or separate classic VPN profiles are common. Check current compatibility before large-scale deployment.

2. How to ensure Headscale high availability?

Place Headscale behind a reverse proxy with health checks, store state in a fault-tolerant DB, deploy a second instance in another AZ/region. Run DERP in at least two regions. Backup configs and DB regularly.

3. What about performance with many nodes?

Hundreds of nodes are common; thousands possible with good architecture and monitoring. Watch handshake times, DERP share, DB load, TLS termination. Separate roles: control plane and DERP instances.

4. Does every node need a public IP?

No. NAT traversal lets clients find direct paths. Public IPs are only needed for Headscale and DERP relays accessible externally.

5. Can you split environments into multiple "organizations"?

Yes, via users/groups and tags. Use separate ACLs for independent teams. For strong isolation, deploy multiple Headscale instances.

6. How to migrate from Tailscale SaaS to Headscale?

Set up Headscale, replicate ACL and groups, issue preauth keys, reconfigure nodes to the new login server in phases. Run parallel networks during migration. Start with non-production nodes.

7. Do Taildrop and similar features work?

File transfers between nodes over the private network are possible, but proprietary user feature behavior may differ from cloud. Test with your client and Headscale versions.

8. How to prevent traffic leaking outside the tunnel?

Use exit nodes and force full traffic routing for sensitive groups. Enable DNS policies. On clients, disallow split tunneling where needed.

9. What does Headscale log? Is it privacy compliant?

Logs include management events: authentication, node registration, policy changes. User traffic does not pass the control plane. Follow your internal data handling and minimization policies.

10. What if my provider blocks UDP?

Expect increased DERP usage. Deploy your own DERP relays close to clients; for critical scenarios, consider TCP tunneling fallback only where needed. Pre-check provider policies.

Conclusion: Who Headscale Is For and How to Get Started Quickly

If you want control, compliance, and predictable pricing, Headscale delivers exactly that. It’s especially great for: 1) homelabs and SMBs needing hassle-free access without port forwarding; 2) product teams with staging and CI/CD across clouds; 3) hybrid projects keeping on-prem databases; 4) industrial scenarios with isolated networks; 5) edge and IoT device fleets; 6) temporary contractor access. Strengths include easy onboarding, flexible ACLs, MagicDNS, routing, and custom DERP options. A productive startup plan looks like: 1) deploy Headscale behind reverse proxy; 2) enable OIDC for onboarding; 3) register first 3–5 nodes; 4) define minimal least-privilege ACL; 5) enable metrics and logging; 6) test two or three key scenarios; 7) scale with tags and subnet routers. For internet exit under personal IPs and enhanced privacy in public networks, classic personal VPNs are a distinct niche. Many teams like personal servers from providers like vpn.how offering dedicated IPs, multiple protocols, geographic choices, fast setup, and transparent pricing. But for internal node networking, DevOps, and hybrid clouds, Headscale remains the better fit. Ultimately, you get a robust private WireGuard network where you control data and management, and onboarding new nodes takes minutes. It’s a rare case where security, convenience, and flexibility truly converge.

Marina Gertner

Marina Gertner

Independent Analyst and Market Researcher

Independent analyst with 11 years of experience in marketing research. Conducted over 200 comparative analyses of services and products. Specializes in objective evaluation of solutions without manufacturer bias.
.
Marketing Research Comparative Analysis Competitive Analysis Evaluation Methodologies Product Management

Share this article: