Monologue Blog

  • 🏡首页
  • 📖文章归档
  • 🚀我的云盘
  • 隐私政策
Monologue Blog
Welcome!
  1. 首页
  2. 技术分享
  3. 正文

Headscale快速搭建derper

2025-02-14 48点热度 0人点赞 0条评论

官方新版本的Derp支持自签证书了

更新软件包,安装依赖

apt update && apt upgrade
apt install -y wget git openssl curl

安装最新版GO

wget https://go.dev/dl/go1.23.5.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.5.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 env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

安装最新版Derper

安装

go install tailscale.com/cmd/derper@latest

拷贝二进制文件

mkdir /etc/derp/
cp ~/go/bin/derper /etc/derp/

查看是否拷贝成功

ls /etc/derp

生成Derper自签证书

DERP_IP=$(curl -s 4.ipw.cn)

openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /root/${DERP_IP}.key -out /root/${DERP_IP}.crt -subj "/CN=${DERP_IP}" -addext "subjectAltName=IP:${DERP_IP}"

mv /root/${DERP_IP}.crt /etc/derp/
mv /root/${DERP_IP}.key /etc/derp/

载入systemd


DERP_IP=$(curl -s 4.ipw.cn)  # Fetch the IP dynamically

# Create the systemd service file with the dynamic IP using EOF
cat <<EOF > /etc/systemd/system/derp.service
[Unit]
Description=TS Derper
After=network.target
Wants=network.target

[Service]
User=root
Restart=always
ExecStart=/etc/derp/derper -hostname ${DERP_IP} -a :12345 -http-port -1 -certmode manual -certdir /etc/derp  --verify-clients
RestartPreventExitStatus=1

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd to apply changes
systemctl daemon-reload

启动

systemctl enable derp
systemctl restart derp
systemctl status derp
本作品采用 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2025-06-23

Monologue

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

COPYRIGHT © 2025 Monologue Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang