最新的tailscale部署自定义derper教程(后台配置有彩蛋)

同步来源:树洞剪藏 源站剪藏 ID:40 原文地址:https://www.nodeseek.com/post-129538-1
最新的tailscale部署自定义derper教程(后台配置有彩蛋)
NodeSeek beta 日常 技术 情报 测评 交易 拼车 推广
最新的tailscale部署自定义derper教程(后台配置有彩蛋)
demeaning 楼主 132days ago edited 132days ago in 技术 #0
date-2024.07--version-1.68.2
前言:鉴于近期tailscale官方对derper版本号调整导致常见教程、脚本和镜像大面积错误,特发此版,若有纰漏请各位不吝指出。
老鸟省时版 : master 版本调整为 latest 版本即解决问题。
即将这句
go install tailscale.com/cmd/derper@master
替换为
go install tailscale.com/cmd/derper@latest
其他不变
分割线 **
以下是无脑完整版(Debian系)
按照惯例先apt
apt update && apt upgrade -y
安装必要组件
apt install -y wget git openssl curl
去Go下载页面检查最新版本
GoDownload
下载对应系统版本的最新Go(本例是amd64)
wget https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
删除老版本Go并安装最新版本
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
修改系统变量
export PATH=$PATH:/usr/local/go/bin
或
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile source /etc/profile
验证版本
go version
洼地需要添加 go 源
go env -w GO111MODULE=on go env -w GOPROXY=https://goproxy.cn,direct
安装 DERPER
go install tailscale.com/cmd/derper@latest
洼地vps需要执行这步
修改cert.go关闭域名验证( 查看刚才安装的derper版本后替换tailscale.com @v1 .1.1-xxxxxxxxxxx)
nano ~/go/pkg/mod/ [email protected] /cmd/derper/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) #//} 把上面这三行注释掉或直接删掉
编译 DERPER( 查看刚才安装的derper版本后替换tailscale.com @v1 .1.1-xxxxxxxxxxx)
cd ~/go/pkg/mod/ [email protected] /cmd/derper go build -o /etc/derp/derper
检查编译结果
ls /etc/derp
回主目录自签10年证书(洼地vps需要执行这步,否则上传证书或用一键脚本签发)
cd ~ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /etc/derp/www.baidu.com.key -out /etc/derp/www.baidu.com.crt -subj "/CN=www.baidu.com" -addext "subjectAltName=DNS:www.baidu.com"
创建derper服务(端口改成自己喜欢的,不要太高)
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 -a :8443 -http-port -1 -stun -stun-port 3478 -hostname www.baidu.com -certmode manual -certdir /etc/derp -verify-clients RestartSec=5 StartLimitInterval=0 [Install] WantedBy=multi-user.target EOF
附:derper命令参数信息,一般不用调整
-a string 服务器HTTP/HTTPS监听地址,格式为":端口","ip:端口",或IPv6的"[ip]:端口"。如果省略IP,默认监听所有接口。如果端口是443和/或 -certmode是manual,则提供HTTPS服务,否则提供HTTP服务。(默认":443") -accept-connection-burst int 接受新连接的突发限制(默认 9223372036854775807) -accept-connection-limit float 接受新连接的速率限制(默认 +Inf) -bootstrap-dns-names string 可选的以逗号分隔的主机名列表,在/bootstrap-dns下可用 -c string 配置文件路径 -certdir string 存储Let'sEncrypt证书的目录,如果addr的端口是:443 (默认 "/root/.cache/tailscale/derper-certs") -certmode string 获取证书的模式。可选 manual, letsencrypt (默认 "letsencrypt") -derp 是否运行DERP服务器。将此设置为false的唯一原因是您要取消commission一个服务器,但仍希望其bootstrap DNS功能继续运行。(默认true) -dev 在localhost开发模式下运行(覆盖-a) -hostname string Let'sEncrypt主机名,如果addr的端口是:443 (默认 "derp.tailscale.com") -http-port int 运行HTTP的端口。设置为-1以禁用。监听器绑定到与-a标志中指定的相同IP(如果有)。(默认80) -mesh-psk-file string 如果非空,则为包含mesh预共享密钥文件的路径。它应该包含一些十六进制字符串;空白将被Trim。 -mesh-with string 可选的以逗号分隔的要mesh的主机名列表;服务器自己的主机名可以在列表中 -stun 是否运行STUN服务器。它将绑定到与--addr标志值相同的IP(如果有)。(默认true) -stun-port int 运行STUN的UDP端口。监听器绑定到与-a标志中指定的相同IP(如果有)。 (默认3478) -unpublished-bootstrap-dns-names string 可选的以逗号分隔的主机名列表,在/bootstrap-dns下可用但不在列表中发布 -verify-clients 通过本地tailscaled实例验证此DERP服务器的客户端。
启用并开机自启derper服务
systemctl daemon-reload systemctl enable derp systemctl start derp
查看服务状态
systemctl status derp
derper服务偶尔会自己莫名挂掉,保险起见需要定时启动服务. 推荐crontab.
systemctl start cron systemctl enable cron systemctl status cron crontab -e
加进定时任务中,无论状态如何,derper每12小时启动一次
0 */12 * * * systemctl start derp
完结撒花,鸡腿给我狠狠地加上
加更,贴下后台配置,主要是端口随机这里"randomizeClientPort": true,官方文档藏得比较深,经测试开了之后打通率会有质变。原理在于如果不开的话tailscale默认用41641,洼地什么绿坝工程、什么为你好项目各种复杂的网络封锁很容易在光猫层面就被堵死导致打洞失败。
// Example/default ACLs for unrestricted connections. { // Declare static groups of users. Use autogroups for all users or users with a specific role. // "groups": { // "group:example": [" [email protected] ", " [email protected] "], // },
// Define the tags which can be applied to devices and by which users. // "tagOwners": { // "tag:example": ["autogroup:admin"], // },
// Define access control lists for users, groups, autogroups, tags, // Tailscale IP addresses, and subnet ranges. "acls": [ // Allow all connections. // Comment this section out if you want to define specific restrictions. { "action": "accept", "src": [""], "dst": [":*"] } ],
// Define users and devices that can use Tailscale SSH. "ssh": [ // Allow all users to SSH into their own devices in check mode. // Comment this section out if you want to define specific restrictions. { "action": "check", "src": ["autogroup:members"], "dst": ["autogroup:self"], "users": ["autogroup:nonroot", "root"] } ],
"nodeAttrs": [ { // Funnel policy, which lets tailnet members control Funnel // for their own devices. // Learn more at https://tailscale.com/kb/1223/tailscale-funnel/ "target": ["autogroup:members"], "attr": ["funnel"] } ],
"randomizeClientPort": true,//这里强烈建议设定为true,贴配置主要就是为了贴它,莫名其妙的打洞失败多少跟它有些关系
// Test access rules every time they're saved. // "tests": [ // { // "src": " [email protected] ", // "accept": ["tag:example"], // "deny": ["100.101.102.103:443"] // } // ],
"derpMap": { "OmitDefaultRegions": false,//这句控制官方derper是否启用,false是启用官方derper,除非特别自信,否则千万不要设置为true "902": { "RegionID": 902, "RegionCode": "xxx", "RegionName": "xxxxxxx", "RegionScore": 0.1//魔法字段,填0~1之间的值会把本区域的derper服务器延迟缩小,比如我填0.1实际延迟是100ms时,后台排序算法会将其标记为10ms,从而实现优选某个区域的derper,一般用不到。当然填大于1的会将排序延迟放大,用来筛选不想使用的derper服务器。 "Nodes": [ { "Name": "xxxxxxx", "RegionID": 902, "HostName": "www.baidu.com",//填自签域名,tsl验证证书用,其实填IP也行,不过为了向后兼容建议填域名 "DERPPort": 8443,//填https也就是上文的:a 后面的端口8443,和derper服务填一样的就行 "IPv4": "x.x.x.x",//HostName如果指定了自签域名,这里必须填上IP地址,否则它真的会去解析www.baidu.com... "IPv6":"x.x.x.x"//同上 "InsecureForTests": true,//这个设置为true,客户端跳过验证,将来可能会被移除,关注官方声明 "STUNPort": 3478//这里可以改,很多教程不让改,其实这个和上文derper服务里面的stunport对应上就可以 } ] } } } }
9 0 33 引用 回复
1 2
yyywww008 132days ago #1
正经技术贴
0 0 引用 回复
zhmsun 132days ago #2
mark
0 0 引用 回复
twws6wai 132days ago #3
什么时候能来个 https://netbird.io/ 的部署教程就好了
也是基于wg封装的,全开源,全平台,就是配置文件看起来头疼
0 0 引用 回复
demeaning 楼主 132days ago #4
感谢大家的鸡腿,忘记后台配置了,一会儿加上
0 0 引用 回复
demeaning 楼主 132days ago #5
@twws6wai #3 看了看好像看不到什么优势,打洞能力强不
0 0 引用 回复
xikk 132days ago #6
tailscale部署derper是用来做什么的呢
卡号代理 全民淘 vpsso 线报发布站防走失 流量永远 特价游玩 特价的-24小时看活动线报,剁手不要停
VX/QQ:11878888 TG:qmtao
0 0 引用 回复
ghostg 132days ago #7
有没有docker一键版本
私信
0 0 引用 回复
coo 132days ago #8
@ghostg #7 我也想问这个
联系我
0 0 引用 回复
digiman 132days ago #9
弯路走完了,给我看这个
0 0 引用 回复
digiman 132days ago #10
@ghostg #7 docker 坑多
0 0 引用 回复
1 2
内容 预览 对照
支持 markdown语法
鼓励友善发言,禁止人身攻击
xxxxxxxxxx
1
1
AC娘
洋葱头
小黄鸡
发布评论
88
等级 Lv 4 鸡腿 1907 关注 0 通知 0
主题帖 10 评论数 290 粉丝 2 收藏 182 发帖
快捷功能区 推荐阅读 管理记录 幸运抽奖 邀请好友 合作商家 友站链接
所有版块 日常 技术 情报 测评 交易 曝光 拼车 生活 贴图 推广 内版 Dev 无意义 沙盒
📈用户数目📈
目前论坛共有22060位seeker
🎉欢迎新用户🎉
alanlu
onvo
无欲无求
KASSA
相关网站 LowEndTalk LowEndSpirit HostLoc ServerHunter
站内导航 关于本站 隐私协议 RSS订阅 sitemap
商业推广 商家申请规则 Premium Provider 合作商家展示
其他平台 电报频道 电报群组
联系我们
Copyright © 2022 - 2024 All rights Reserved