【赚点积分】在leaflow上部署自己的tailscale dreper中继节点

参照 906051999大佬的原贴【最好的虚拟组网】为Tailscale部署使用IP的Derp节点
在leaflow上部署了自己的tailscale drep节点,水一贴,赚点积分

  1. 镜像选择:选用这个镜像(https://hub.docker.com/r/yangchuansheng/ip_derper)
    只使用TCP和UDP两个端口
  2. leaflow部署
    在leaflow上新建应用
    名称随便起,镜像使用上述镜像
    因为只是中继节点,打洞成功后所有流量不需要经过中继节点,内存分配128M、CPU200毫核就够了

    正常使用情况下其实开销很小

暴露端口


然后就可以启动应用了
开通外网服务:
直接选择目标工作负载,会自动帮你设置好映射端口


选择好会话保持和外部流量策略,开通服务即可


可以看到公网IP地址


3. tailscale设置
直接拷贝大佬的原文了
接下来去tailscale控制台配置derp服务地址:

// 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 grants that govern access for users, groups, autogroups, tags,
	// Tailscale IP addresses, and subnet ranges.
	"grants": [
		// Allow all connections.
		// Comment this section out if you want to define specific restrictions.
		{"src": ["*"], "dst": ["*"], "ip": ["*"]},

		// Allow users in "group:example" to access "tag:example", but only from
		// devices that are running macOS and have enabled Tailscale client auto-updating.
		// {"src": ["group:example"], "dst": ["tag:example"], "ip": ["*"], "srcPosture":["posture:autoUpdateMac"]},
	],

	// Define postures that will be applied to all rules without any specific
	// srcPosture definition.
	// "defaultSrcPosture": [
	//      "posture:anyMac",
	// ],

	// Define device posture rules requiring devices to meet
	// certain criteria to access parts of your system.
	// "postures": {
	//      // Require devices running macOS, a stable Tailscale
	//      // version and auto update enabled for Tailscale.
	// 	"posture:autoUpdateMac": [
	// 	    "node:os == 'macos'",
	// 	    "node:tsReleaseTrack == 'stable'",
	// 	    "node:tsAutoUpdate",
	// 	],
	//      // Require devices running macOS and a stable
	//      // Tailscale version.
	// 	"posture:anyMac": [
	// 	    "node:os == 'macos'",
	// 	    "node:tsReleaseTrack == 'stable'",
	// 	],
	// },

	// 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:member"],
			"dst":    ["autogroup:self"],
			"users":  ["autogroup:nonroot", "root"],
		},
	],

	// 自定义derpMap
	"randomizeClientPort": false, // 随机端口, 防止被NAT或防火墙限制
	"derpMap": {
		"OmitDefaultRegions": false, // 只用自己的节点不用官方节点。
		"Regions": {
			"900": {
				"RegionID":   900, // tailscale 900-999 是保留给自定义 derper 的
				"RegionCode": "alicloud", // 随便命名
				"RegionName": "leaflow shenzhen", // 随便命名
				"Nodes": [
					{
						"Name":             "900", //复制自derper的输出信息
						"RegionID":         900, //复制自derper的输出信息
						"HostName":         "【IP】", // 改成服务器公网IP
						"DERPPort":         10042, // Derp 服务端口
						"STUNPort":         10046, // STUN 端口
						"InsecureForTests": true,
						"IPv4":             "【IP】", // 改成服务器公网IP
					},
				],
			},
			"1": null,
			"2": null,
			// "3": null, // Singapore
			"4": null,
			// "5": null, // Sydney
			"6": null,
			// "7": null, // Tokyo
			"8":  null,
			"9":  null,
			"10": null,
			"11": null,
			"12": null,
			"13": null,
			"14": null,
			"15": null,
			"16": null,
			"17": null,
			"18": null,
			"19": null,
			// "20": null, // Hong Kong
			"21": null,
			"22": null,
			"23": null,
			"24": null,
			"25": null,
		},
	},

	// Test access rules every time they're saved.
	// "tests": [
	//  	{
	//  		"src": "[email protected]",
	//  		"accept": ["tag:example"],
	//  		"deny": ["100.101.102.103:443"],
	//  	},
	// ],
}

  1. tailscale测试
    更换derp节点需要客户端重启tailscale才能生效,不然使用的时候还是会用之前的derp节点。群晖就直接在套件中心停用再启用tailscale就行。

我们来测试一下节点情况,在Windows的tailscale路径下cmd执行即可(群晖ssh也行)

首先关闭ipv6,避免直接公网直连,然后找到一台用流量的手机,连入tailscale:

  • 查询集群状态
tailscale status  
100.64.205.77   officenas-1          zbigbird@    linux   -
100.77.234.40   huawei-icl-al10      zbigbird@    android offline

# Health check:
#     - Tailscale could not connect to the 'leaflow shenzhen' relay server. Your Internet connection might be down, or the server might be temporarily unavailable.
  • 查询网络状态
tailscale netcheck  
Report:
        * Time: 2025-09-19T10:28:43.058020358Z
        * UDP: true
        * IPv4: yes, 10.0.1.51:36297
        * IPv6: no, but OS has support
        * MappingVariesByDestIP: true
        * PortMapping: UPnP
        * CaptivePortal: false
        * Nearest DERP: leaflow shenzhen
        * DERP latency:
                - alicloud: 8.5ms   (leaflow shenzhen)
                - hkg: 153.3ms (Hong Kong)
                - nue: 186.3ms (Nuremberg)
                - iad: 215.2ms (Ashburn)
                - hel: 217.2ms (Helsinki)
                - sin: 237.5ms (Singapore)
                - tok: 240.2ms (Tokyo)
                - syd: 303.5ms (Sydney)
  • ping一下使用流量上网的手机
tailscale ping 100.77.234.40
pong from huawei-icl-al10 (100.77.234.40) via 192.168.123.70:33247 in 36ms

ipv4 STUN打洞成功,延迟36ms!

17 个赞

厉害啊佬

1 个赞

佬太强了~

w 感谢分享喵~(瘫

感谢分享

感谢大佬教程。

你在那个集群 十堰 还是深圳

深圳集群

一个月大概多少钱?我服务器马上到期了 derper 也要想办法了

目前看5块钱

那不划算啊 还不如在腾讯或者阿里、京东搞个服务器了

谢谢佬的教程

有点厉害呀,佬

大佬 为什么我跟着教程创建了一个十堰的 延迟一直都是400多呀 都自动给我选到国外的derp了

没事儿了老哥 走了代理:joy:

ip_derper 这个仓库用的 derper 已经很久没更新了。现在可以直接用官方 derper,官方已经支持使用 IP,当 hostname 指定为 ip 时会自动自签 ip 证书,启动时也会输出自签证书指纹。

stun port 不需要 TCP,只需要 UDP。这样端口映射能少一个。

其实一个人用,可以再省点配置,100毫秒核 + 64M 内存也能跑……