Hacker News 中文摘要

RSS订阅

Show HN: TailGuard – 通过容器将WireGuard路由器桥接到Tailscale -- Show HN: TailGuard – Bridge your WireGuard router into Tailscale via a container

文章摘要

TailGuard是一个简单的Docker容器应用,用于将现有的WireGuard服务器连接到Tailscale网络,特别适用于无法直接运行Tailscale的设备。通过TailGuard服务器,所有与WireGuard的连接都通过固定且持久的隧道进行,确保安全性和稳定性。这种方法的主要优势是WireGuard隧道的私钥仅存储在一台机器上,提高了安全性。

文章总结

TailGuard:容器中的Tailscale与WireGuard桥接工具

TailGuard是一个简单的Docker容器应用,旨在将现有的WireGuard服务器连接到Tailscale网络。该工具特别适用于运行WireGuard的设备被锁定或无法支持Tailscale二进制文件的情况。

网络拓扑

TailGuard的网络拓扑大致如下:

+---------+ | device1 |\ +---------+ \ VPS +---------+ \ +---------+ +-----------+ +-----------+ | device2 |----| tailnet |----| TailGuard |<---->| WireGuard | +---------+ / +---------+ +-----------+ +-----------+ +---------+ / | device3 |/ +---------+

Tailnet是虚拟的,实际连接是点对点的,但所有到WireGuard的连接都通过TailGuard服务器进行隧道传输,并保持固定和持久的连接。只要你能访问一个尽可能靠近WireGuard服务器的服务器(例如VPS),你就可以将任何WireGuard设备连接到你的tailnet。

优势

使用TailGuard桥接方法有以下好处:

  • 简化密钥管理:WireGuard隧道的私钥仅存储在一台机器上,减少了密钥管理的工作量。
  • 新设备接入便捷:只需通过SSO登录tailnet,无需传输密钥。
  • 切换出口节点更轻松:无需重新连接不同的VPN,即可在tailnet中切换出口节点。
  • 移动设备支持:在支持多个VPN的移动设备上,可以同时访问tailnet和WireGuard。
  • 路由器支持:通过仅支持WireGuard但不支持Tailscale的路由器,将家庭网络连接到tailnet。

安装

启动TailGuard的最简单方法是下载WireGuard客户端配置文件并保存为wg0.conf。然后创建一个IPv6网络(可选但推荐),并启动容器:

bash docker network create --ipv6 ip6net docker run -it \ -v ./wg0.conf:/etc/wireguard/wg0.conf -v ./state:/tailguard/state \ --cap-add NET_ADMIN --device /dev/net/tun \ --sysctl net.ipv4.ip_forward=1 --sysctl net.ipv6.conf.all.forwarding=1 \ --sysctl net.ipv4.conf.all.src_valid_mark=1 \ --network ip6net -p 41641:41641/udp \ --name tailguard juhovh/tailguard:latest

Docker会打印一个URL,你需要登录到你的tailnet,之后即可使用。

如果你想自己构建最新版本的镜像,建议使用docker compose。将wg0.conf文件存储在config/目录下,使用docker compose build构建最新镜像,最后使用docker compose up运行。

高级设置

假设你有一个运行在10.1.0.1的WireGuard服务器,能够接受任何路由,其本地LAN网络为192.168.8.0/24。确保在AllowedIPs部分明确提到子网192.168.8.0/24,以便TailGuard识别。配置文件示例如下:

```ini [Interface] PrivateKey = Address = 10.1.0.2/24,fd00:ed7c:a960:6e9b::2/64 DNS = 10.1.0.1,fd00:ed7c:a960:6e9b::1 MTU = 1420

[Peer] PublicKey = PresharedKey = AllowedIPs = 0.0.0.0/0, ::/0, 192.168.8.0/24 Endpoint = :51820 PersistentKeepalive = 25 ```

你可以通过环境变量TS_DEST_IP=10.1.0.1或修改docker-compose.yml来指定目标IP。

双向路由

与Tailscale不同,WireGuard本身不处理任何路由。因此,WireGuard子网和路由会自动在Tailscale网络上通告,但反之则不行。你可以通过以下命令添加路由:

bash ip route add 100.64.0.0/10 via 10.1.0.2 dev wgserver ip route add fd7a:115c:a1e0::/48 via fd00:ed7c:a960:6e9b::2 dev wgserver

如果有其他子网需要访问,只需添加类似的路由规则。TailGuard会负责将所有发布的子网转发到tailnet,只要它能通过WireGuard隧道接收数据包。

许可证

TailGuard采用MIT许可证,允许自由使用、修改和分发软件。

评论总结

评论主要围绕Tailscale和WireGuard的功能、集成及使用体验展开,观点多样且涉及技术细节。以下是总结:

  1. 关于Tailscale的Subnet Router功能

    • 有评论提到Tailscale的Subnet Router功能,并质疑为何需要大量代码来实现类似功能。
    • 引用:
      • "Can't you simply enable subnet routing on the tailscale node (single argument does that)?"
      • "What about the Subnet Router functionality that Tailscale has?"
  2. 与fly.io的集成可能性

    • 有评论探讨Tailguard是否可以通过WireGuard与fly.io的服务器连接。
    • 引用:
      • "So, it looks like this might work with fly.io?"
      • "fly.io provides a way to connect to their servers via wireguard."
  3. 5G路由器的使用建议

    • 有评论建议使用内置Tailscale和WireGuard的5G GL.inet路由器,认为其更稳定且支持IMEI克隆。
    • 引用:
      • "Neat idea but getting a 5G GL inet router would probably be more robust."
      • "Best thing about GL inet routers are the IMEI cloning."
  4. 与其他VPN的兼容性问题

    • 有评论提到Tailscale与其他VPN的兼容性问题,尤其是手机端仅支持一个VPN应用的限制。
    • 引用:
      • "It also doesn't play nicely together with other VPNs."
      • "I've had great luck using specific routes over wireguard with the official app on my phone."
  5. 对README.md的肯定

    • 有评论赞赏了README.md的清晰结构和内容。
    • 引用:
      • "The overview and benefits sections along with other bits are great examples of what should go in a root level README.md."

总结:评论主要关注Tailscale和WireGuard的功能集成、与其他服务的兼容性以及使用体验,同时提供了技术建议和对文档的肯定。