自建 Tailscale DERP 的一次尝试

也是用上

一,安装并启动 Tailscale

curl -fsSL https://tailscale.com/install.sh | sh && tailscale up --netfilter-mode=off --accept-dns=false

二,更新软件源并安装 Golang 最新版

apt update && apt upgrade
# 安装相关依赖
apt install -y wget git openssl curl

# 可打开https://go.dev/dl/查看最新版本
cd /root
wget https://go.dev/dl/go1.25.1.linux-amd64.tar.gz

# 解压
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.25.1.linux-amd64.tar.gz

# 查看版本
export PATH=$PATH:/usr/local/go/bin
go version

# 添加环境变量
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile

# 让 Go 使用国内代理源(国外主机忽略)
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

三,部署 DERP

# 拉取derper包
go install tailscale.com/cmd/derper@main

# 进入到编译好的文件夹(不要直接复制命令,按实际情况填写)
cd /root/go/pkg/mod/tailscale.com@v1.75.0-xxxx/cmd/derper/

# 打开cert.go文件
vi cert.go

# 注释以下信息-跳过证书验证
func (m *manualCertManager) getCertificate(hi *tls.ClientHelloInfo) (*tls.Certificate, error) {
    // if hi.ServerName != m.hostname {
    //     return nil, fmt.Errorf("cert mismatch with hostname: %q", hi.ServerName)
    // }

# 编译并输出到/etc/derp/
go build -o /etc/derp/derper

# 查看是否存在derper文件
cd /root
ls /etc/derp

# 自签域名(derp.myself.com可随意编写,命令中四处需要一致)
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /etc/derp/derp.myself.com.key -out /etc/derp/derp.myself.com.crt -subj "/CN=derp.myself.com" -addext "subjectAltName=DNS:derp.myself.com"

四,配置开机自启(启动命令的域名记得改)

cat > /etc/systemd/system/derp.service <<EOF
[Unit]
Description=TS Derper
After=network.target
Wants=network.target
[Service]
User=root
Restart=always
ExecStart=/etc/derp/derper -hostname derp.myself.com -a :33445 -http-port 33446 -verify-clients -certmode manual -certdir /etc/derp
RestartPreventExitStatus=1
[Install]
WantedBy=multi-user.target
EOF

开放 33445/TCP 和 3478/UDP 端口

随后访问 https://IP:33445 查看 DERP 服务是否启动成功

五,进入 Tailscale AccessControl 页面加入如下配置

// Tailscale DERP
    "derpMap": {
        // OmitDefaultRegions 用来禁用官方的中继节点
        "OmitDefaultRegions": true,
        "Regions": {
            "901": {
                "RegionID":   901, // 901 三个地方保持一致,900开始,多个节点可以往后+1
                "RegionCode": "us",
                "RegionName": "US",
                "Nodes": [
                    {
                        "Name":             "Cloudflare-DNS",
                        "RegionID":         901,
                        "IPv4":             "1.1.1.1", // 改成你的公网IP
                        "DERPPort":         33445,
                        "InsecureForTests": true,
                    },
                ],
            },
        },
    },

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇