mac上设置Tailscale强制走Derp中转

学校的 wifi 有 ap 隔离,在同一wifi下使用 Tailscale 打洞连接极其不稳定,于是设置了强制Tailscale走Derp中转(顺便吐槽宿舍的有限网口居然只是摆设…)。Tailscale 预留了专门用于开发测试的环境变量:TS_DEBUG_ALWAYS_USE_DERP=true,带上变量启动即可:

1
TS_DEBUG_ALWAYS_USE_DERP=true tailscaled

安装并配置 Tailscale

安装:

1
brew install tailscale

配置启动文件:

1
sudo vim /Library/LaunchDaemons/com.custom.tailscaled.plist

内容为:

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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.custom.tailscaled</string>

<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/tailscaled</string>
</array>

<key>EnvironmentVariables</key>
<dict>
<key>TS_DEBUG_ALWAYS_USE_DERP</key>
<string>true</string>
</dict>

<key>RunAtLoad</key>
<true/>

<key>KeepAlive</key>
<true/>

<key>StandardErrorPath</key>
<string>/var/log/tailscaled.log</string>
<key>StandardOutPath</key>
<string>/var/log/tailscaled.log</string>
</dict>
</plist>

设置正确的权限:

1
2
sudo chown root:wheel /Library/LaunchDaemons/com.custom.tailscaled.plist
sudo chmod 644 /Library/LaunchDaemons/com.custom.tailscaled.plist

加载并启动服务
使用 launchctl 加载这个配置,它会立即启动,并且在以后每次 Mac 开机时自动在后台运行:

1
sudo launchctl load -w /Library/LaunchDaemons/com.custom.tailscaled.plist

登录 tailescale

1
tailscale up --login-server https://xxx --hostname xx

检查是否只走derp,ping一下其他机器:

1
tailscale ping xxx

mac上设置Tailscale强制走Derp中转

https://psu.monster/post/2026/068424c1798c

作者

psu

发布于

2026-03-08

更新于

2026-03-08

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×