首先感谢 @韩风 大佬提供的方法
大佬B站主页:韩风Talk的个人空间-韩风Talk个人主页-哔哩哔哩视频
前期准备:
- 云服务器或vps一台
- FinalShell或其他支持编辑主机内文件的ssh工具
apt update && apt upgrade
####依次执行下面代码########
apt install -y wget git openssl curl
#####下面要修改#########
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.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
go install tailscale.com/cmd/derper@main
#########下面要改##########
cd /root/go/pkg/mod/tailscale.com@v1.1.1-0.20240103195734-e32a06465903/cmd/derper
########上面要改#############
go build -o /etc/derp/derper
cd
ls /etc/derp
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 -certmode manual -certdir /etc/derp
RestartPreventExitStatus=1
[Install]
WantedBy=multi-user.target
EOF
systemctl enable derp
systemctl start derp
"derpMap": {
"OmitDefaultRegions": true,
"Regions": {
"901": {
"RegionID": 901,
"RegionCode": "Myself",
"RegionName": "Myself Derper",
"Nodes": [
{
"Name": "901a",
"RegionID": 901,
"DERPPort": 33445,
"IPv4": "服务器IP",
"InsecureForTests": true,
},
],
},
},
},
如果服务器IP地址和端口泄露了 那么是可以被别人白嫖的
所以
防白嫖操作:
回到FinalShell,执行这行代码
curl -fsSL https://tailscale.com/install.sh | sh
?执行这行代码
nano /etc/systemd/system/derp.service
快捷键:Ctrl?+ X 保存
保存成功后再执行以下代码
systemctl daemon-reload
systemctl restart derp
好 这样操作完后 别人就无法白嫖了
END