使用 headscale 自建 tailscale 控制中心
- Published on
本文最近一次更新于 582 个天前,其中的内容很可能已经有所发展或是发生改变。
前言
Tailscale 控制服务器可以使用 headscale 自建,本文主要是记录下 headscale 的 docker-compose 部署。
Headscale部署
docker-compose 部署
version: '3.5'
services:
headscale:
image: headscale/headscale:latest
volumes:
- ./config:/etc/headscale/
- ./data:/var/lib/headscale
ports:
- 27896:8080
command: headscale serve
restart: unless-stopped
目前官方没有 ui,如果需要 web 界面控制,可以使用第三方的 ui
https://github.com/gurucomputing/headscale-ui
生成配置文件
wget https://github.com/juanfont/headscale/raw/main/config-example.yaml -O ./config/config.yaml
修改配置参数
config.yaml
---
# headscale will look for a configuration file named `config.yaml` (or `config.json`) in the following order:
#
# - `/etc/headscale`
# - `~/.headscale`
# - current working directory
# The url clients will connect to.
# Typically this will be a domain like:
#
# https://myheadscale.example.com:443
#
server_url: http://你的地址:8080
# Address to listen to / bind to on the server
#
# For production:
# 这里要用 0.0.0.0
listen_addr: 0.0.0.0:8080
#listen_addr: 127.0.0.1:8080
......
# List of IP prefixes to allocate tailaddresses from.
# Each prefix consists of either an IPv4 or IPv6 address,
# and the associated prefix length, delimited by a slash.
# It must be within IP ranges supported by the Tailscale
# client - i.e., subnets of 100.64.0.0/10 and fd7a:115c:a1e0::/48.
# See below:
# IPv6: https://github.com/tailscale/tailscale/blob/22ebb25e833264f58d7c3f534a8b166894a89536/net/tsaddr/tsaddr.go#LL81C52-L81C71
# IPv4: https://github.com/tailscale/tailscale/blob/22ebb25e833264f58d7c3f534a8b166894a89536/net/tsaddr/tsaddr.go#L33
# Any other range is NOT supported, and it will cause unexpected issues.
ip_prefixes:
# 注释这里是不使用 ipv6,我的 tailscale是 ipv4网段的设置
#- fd7a:115c:a1e0::/48
- 100.64.0.0/10
.....
运行
docker-compose up -d
使用 Headscale 作为控制器
mac
输入 http://ip:27896/apple
就可以看到在 macos 以及 iOS 上替换过程 以我的 macbook pro 为例,我安装的是 tailscale 非 apple store 的版本,那么我就需要先在命令行上替换 tailcale 的控制链接,然后登录就可以。
defaults write io.tailscale.ipn.macsys ControlURL http://ip:27896
linux
linux 环境下,安装 tailscale 客户端
tailscale login --login-server http://ip:27896