Post

无域名搭建 DERP 服务器

无域名搭建 DERP 服务器

官方版本的 derper 已经支持使用纯 IP 地址搭建 DERP 服务器

详见:#11776#3647

本文参考:https://www.cnblogs.com/yafengabc/p/18591222

1 安装 Go 语言环境

  1. 下载 Go 压缩包,并安装
  2. 配置加速镜像:go env -w GOPROXY=https://goproxy.cn,direct

2 安装 derper

1
go install tailscale.com/cmd/derper@latest

3 生成自签名证书

1
2
3
mkdir -p ~/derp-certs && cd ~/derp-certs
DERP_IP="12.12.12.12" # 替换为你的服务器公网 IP 地址
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout ${DERP_IP}.key -out ${DERP_IP}.crt -subj "/CN=${DERP_IP}" -addext "subjectAltName=IP:${DERP_IP}"

4 运行 derper

1
sudo derper --hostname="12.12.12.12" -certmode manual -certdir ~/derp-certs

5 配置 Tailscale 使用自定义 DERP 服务器

在 Tailscale Access Controls 页面添加如下配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    "derpMap": {
        "OmitDefaultRegions": true, // 表示不使用官方 DERP 服务器
        "Regions": {
            "901": {
                "RegionID":   901,
                "RegionCode": "custom-derper",
                "RegionName": "MyCloud",
                "Nodes": [
                    {
                        "Name":             "custom-derper",
                        "RegionID":         901,
                        "HostName":         "12.12.12.12",
                        "InsecureForTests": true,
                    },
                ],
            },
        },
    },
This post is licensed under CC BY 4.0 by the author.