TailScale子网路由设置
通过设置子网路由设置,让子网路由器充当网关,将流量从Tailscale网络中继到物理子网来,访问这些没接入tailscale组网的设备(如打印机、嵌入式设备等)。也就是说,内网地址可以在局域网中使用,也可以在加入tailscale组网的机器中远程直接访问。
1.配置子网路由
tailscale up --advertise-routes=192.168.0.0/24,192.168.1.0/24
将上述示例中的子网替换为适合您网络的子网。支持IPv4和IPv6子网。
如果设备由可以在autoApprovers
中分发指定路由的用户进行身份验证,那么子网路由器的路由将自动获得批准。您还可以在tailnet策略文件中公布autoApprovers
允许的路由的任何子集。
注:Linux系统需要启用IP转发
如果您的Linux系统有一个/etc/sysctl.d目录,请使用:
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
否则,请使用:
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
2.从管理控制台启用子网路由
打开管理控制台的[机器]页面,找到分发子网路由的设备。打开Edit route settings面板。
通过单击路线左侧的开关来批准路线。
3.为分发子网路由添加访问规则
如果您已经有允许访问分发子网路由的规则,则不需要此步骤。
此访问规则的作用:
- Members of the development team group:dev can access devices in the subnets 192.168.0.0/24 and 192.168.1.0/24.
- The subnet 192.168.0.0/24 can access the subnet 192.168.1.0/24 and vice versa, if subnet route masquerading is disabled.
{
"groups": {
"group:dev": ["alice@example.com", "bob@example.com"]
},
"acls": [
// Users in group:dev and devices in subnets 192.168.0.0/24 and
// 192.168.1.0/24 can access devices in subnets 192.168.0.0/24 and
// 192.168.1.0/24
{ "action": "accept",
"src": ["group:dev","192.168.0.0/24", "192.168.1.0/24"],
"dst": ["192.168.0.0/24:*", "192.168.1.0/24:*"]
}
]
}
- 在开启tailscale客户端,输入内网IP,直接远程访问。