免域名 tailscale derp 搭建

免域名 tailscale derp 搭建

Neurocoda

#Tailscale #中继服务 #内网穿透

Tailscale 部署

1
curl -fsSL <https://tailscale.com/install.sh> | sh

tailscale 若通过 docker 搭建,可能会导致搭建 docker derper 鉴权错误 (似乎是因为进程通信条件:与 tailscaled 通信不满足)

这里一键脚本搭建好后进行登录操作:

1
tailscale login

Derper 部署

创建 docker-compose.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
services:
derper:
image: ghcr.io/yangchuansheng/ip_derper:latest
container_name: derper
restart: always
ports:
- "25425:25425" # 这里的25425请改成你自己想要的10000以上的高位端口
- "3478:3478/udp" # 3478 为stun端口,如果不冲突请勿修改
volumes:
- /var/run/tailscale/tailscaled.sock:/var/run/tailscale/tailscaled.sock # 映射本地 tailscale 客户端验证连接,用来验证是否被偷
environment:
- DERP_ADDR=:25425 # 此处需要与上面的同步修改
- DERP_CERTS=/app/certs
- DERP_VERIFY_CLIENTS=true # 启动客户端验证,这是防偷的最重要的参数

注意,其中端口映射部分(12345:12345) 后部分的 12344 取决于环境变量 DERP_ADDR

持久化数据部分,可通过 find / -name "tailscaled.sock" 指令查找。

编写好后 docker-compose up -d 运行容器即可

注:若 ghcr.io/yangchuansheng/ip_derper:latest 无法使用,可通过 Dockerfile 自行编译。(项目地址

Tailscale Console 配置

去 Tailscale 网页控制台,进入 ALC 编辑界面,插入下面的文本即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"derpMap": {
"OmitDefaultRegions": false, // 可以设置为 true,这样不会下发官方的 derper 节点,测试或者实际使用都可以考虑打开
"Regions": {
"900": {
"RegionID": 900, // tailscale 900-999 是保留给自定义 derper
"RegionCode": "abc1",
"RegionName": "abcc1",// 这俩随便命名
"Nodes": [
{
"Name": "fff",
"RegionID": 900,
"IPv4": "1.1.1.1", // 你的VPS 公网IP地址
"DERPPort": 12345, //上面 12345 你自定义的端口
"InsecureForTests": true, // 因为是自签名证书,所以客户端不做校验
},
],
},
"901": {
"RegionID": 901, // 加入新 derp 的时候记得修改
"RegionCode": "abc2",
"RegionName": "abcc2",
"Nodes": [
{
"Name": "kkk",
"RegionID": 902,
"IPv4": "8.8.8.8", // 你的VPS 公网IP地址
"DERPPort": 4000, //上面 12345 你自定义的端口
"InsecureForTests": true, // 因为是自签名证书,所以客户端不做校验
},
],
},
},
},

参考:
https://blog.sleepstars.net/archives/ji-yu-docker-compose

  • Title: 免域名 tailscale derp 搭建
  • Author: Neurocoda
  • Created at : 2025-01-13 11:25:06
  • Updated at : 2025-01-13 11:25:06
  • Link: https://neurocoda.com/p/e68688e7.html
  • License: This work is licensed under CC BY-ND 4.0.
Comments
On this page
免域名 tailscale derp 搭建