DEV Community

Cover image for Setting Up Your Own Tailscale Control Server with Headscale
Mustafa ERBAY
Mustafa ERBAY

Posted on • Originally published at mustafaerbay.com.tr

Setting Up Your Own Tailscale Control Server with Headscale

Introduction

Headscale is an open-source application of the Tailscale control server, allowing users to set up their own Tailscale-compatible control servers. This provides more flexibility in managing your mesh-VPN network and customizing security settings. In this article, you will learn the steps to set up your own Tailscale control server with Headscale.

What is Headscale?

Headscale is an open-source application of the Tailscale control server. Tailscale is a modern VPN solution built on WireGuard, enabling users to securely access remote devices. While Tailscale's managed service does not offer a self-hosted control server option, Headscale provides an open-source alternative for self-hosting and hobbyist users.

Setting Up Your Own Tailscale Control Server with Headscale

To set up your own Tailscale control server with Headscale, follow these steps:

Step 1: Install Headscale

To install Headscale, you first need a server or virtual machine. After setting up your server or virtual machine, you can install Headscale. Headscale is officially available on Docker Hub and can be installed using Docker.

In production environments, it is recommended to use a specific version instead of the 'latest' tag. The following command pulls the latest stable version of Headscale:

docker pull headscale/headscale:0.23.0 # Example version, check the current stable version
Enter fullscreen mode Exit fullscreen mode

Warning: Instead of the 'latest' tag, it is recommended to always use the current stable version number (e.g., 0.23.0) from Headscale's official GitHub release page when pulling the Docker image. This helps avoid unexpected changes.

Step 2: Configure Headscale

After installing Headscale, you can configure it using the following commands. This command runs Headscale on port 8080 by default and mounts its configuration to the /etc/headscale directory.

First, you need to create and edit the Headscale configuration file (e.g., config.yaml) on your server. Headscale looks for the configuration file in /etc/headscale, $HOME/.headscale, or the current working directory. You can download an example configuration file from the Headscale GitHub repository.

# Example: Create the configuration directory
mkdir -p /var/lib/headscale # Or your preferred directory

# Example: Download the current configuration example from Headscale's GitHub repository
# Replace HEADSCALE_VERSION with the current stable version (e.g., 0.23.0)
# wget -O /var/lib/headscale/config.yaml https://github.com/juanfont/headscale/raw/v${HEADSCALE_VERSION}/config-example.yaml
# nano /var/lib/headscale/config.yaml # Edit the configuration file
Enter fullscreen mode Exit fullscreen mode

Then, start Headscale with Docker:

docker run -d --name headscale \
  -p 8080:8080 \
  -v /var/lib/headscale:/etc/headscale \
  headscale/headscale:0.23.0 # Example version, use the current stable version
Enter fullscreen mode Exit fullscreen mode

This command runs Headscale on port 8080 and mounts its configuration from /var/lib/headscale to /etc/headscale in the container.

Step 3: Install Tailscale

After installing Headscale, you can install the Tailscale client. Tailscale has different installation methods for various platforms. For more information, refer to the Tailscale documentation.

Step 4: Connect Tailscale to Headscale

After installing the Tailscale client, you can connect it to your Headscale server using the following command:

tailscale up --login-server http://<HEADSCALE_SERVER_ADDRESS_OR_IP>:8080
Enter fullscreen mode Exit fullscreen mode

This command connects the Tailscale client to your Headscale server. Replace <HEADSCALE_SERVER_ADDRESS_OR_IP> with the actual IP address or domain name of your Headscale server. For example, if your Headscale server is running at myheadscale.example.com, the command would be tailscale up --login-server http://myheadscale.example.com:8080.

Managing Your Own Tailscale Control Server with Headscale

After setting up your own Tailscale control server with Headscale, you can use Headscale to manage your mesh-VPN network. Headscale provides full control over the control plane, in addition to many features found in Tailscale's managed service.

Security Settings

Headscale offers similar security options to Tailscale and provides full control over your environment. For example, with Headscale, you can use your own SSL/TLS certificates and manage TLS configuration.

Network Management

Headscale provides various tools for managing your network. For example, with Headscale, you can manage access control lists (ACLs), control node registration, and customize your network security settings.

Conclusion

Setting up your own Tailscale control server with Headscale provides more flexibility and control in managing your mesh-VPN network and customizing security settings. In this article, you learned the steps to set up your own Tailscale control server with Headscale. Headscale is an open-source application of the Tailscale control server, allowing users to self-host their own Tailscale-compatible networks.

Official Resources

Top comments (0)