10

tailscale自定义derp服务器搭建

 1 year ago
source link: https://www.bboy.app/2023/04/23/tailscale%E8%87%AA%E5%AE%9A%E4%B9%89derp%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

tailscale自定义derp服务器搭建

April 23, 2023

20230423-1.webp

因为tailscale价格调整的原因,我突然发现使用headscale还不如直接使用tailscale,这样不仅可以让我的2g内存小机器降低负载还可以让我少维护一个服务,但是因为是国内的原因,有时候tailscale的服务体验不会很好,tailscale所有的中继服务器都是在国外的,所以自建DERP服务器会让你的体验更上一层。

首先安装go

wget https://go.dev/dl/go1.20.3.linux-amd64.tar.gz

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.3.linux-amd64.tar.gz

修改GOPROXY

go env -w GOPROXY=https://goproxy.cn,direct

之后安装derper

go install tailscale.com/cmd/derper@main

默认安装好的二进制文件会在$HOME/go/bin

之后启动derper服务器

nohup ./derper --hostname=1.1.1.1 &

注意hostname是你的服务器ip地址或者是服务器的域名

注意,任何知道你的域名和服务器ip的人都是可以直接白嫖你的节点的,所以要在你derper的服务器上启动tailscaled,并且启动时候加上--verify-clients参数才可以不被白嫖

最后在acl配置里面加上你的derp节点

https://login.tailscale.com/admin/acls

	"derpMap": {
		"Regions": {
			"900": {
				"RegionID":   900,
				"RegionCode": "myderp",
				"Nodes": [
					{
						"Name":     "1",
						"RegionID": 900,
						"HostName": "1.1.1.1",
					},
				],
			},
		},
	},

同理这里的1.1.1.1也是你的服务器ip地址或者是域名

接着你可以测试下,断开网络中的一台机器的tailscale链接,然后重新链接

如果在节点的详细信息中出现了

Relay #900: 18.41 ms

那么表示你的这个客户端已经使用你的derp节点了

欢迎关注我的博客www.bboy.app

Have Fun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK