思路
背景: 公司允许自带电脑办公,我一般带自己的 MacBook 上班。 部分内网通过 VPN 访问,但客户端不是只有 windows 版,就是权限高装根证书的流氓软件,自己电脑装这东西有点恶心,但又需要访问内网。
参考科学上网方法就简单了:让公司发的 windows 装 vpn 并开启服务端代理,之后在 mac 上使用 surge/clash 添加 vpn 代理节点和内网分流规则,就得到了内外网自动分流的上网体验。
工具选用:
sing-box: 配置简单,用于在装了 vpn 的 Windows 上开启代理服务端,局域网直接连它即可。Tailscale: 跨网连接时,我将它仅作为链式代理的中继 (Tailscale 就是组网用的,直接访问 VPN 内网需配置子网路由、转发和访问权限。我的需求开始只有局域网,后来才有的跨网,将它作为链式中继配置足够简单)
Company / LAN Home / WAN
+---------------------------+ +------------------------------------+
| MacBook (Surge / Clash) | | Mac mini (Surge / Clash) |
| proxy node: work_lan | | proxy node: work_wan |
| Server: Windows LAN IP | | Server: Windows Tailscale IP |
+-------------+-------------+ | | |
| | Proxy chain via Tailnet |
| | v |
SS 2022 / TCP | Embedded Tailscale outbound |
| +------------------+-----------------+
| |
LAN SS 2022 / TCP over Tailnet
| (P2P direct / DERP relay)
v v
+---------------------------------------------------------------------+
| Company Windows |
| LAN IP : port Tailscale client |
| | | |
| | IP : port |
| | | |
| +------------------+------------------+ |
| v |
| sing-box / SS 2022 inbound |
| | new TCP connection |
| v |
| Windows routing table |
| | VPN route |
| v |
| Existing VPN client |
| | |
+--------------------------------+------------------------------------+
| VPN tunnel
v
+---------------------------+
| Internal services |
+---------------------------+
work_lan 和 work_wan 是代理规则中用于访问公司内网的节点,一个用于局域网,一个用于跨网。跨网使用链式代理,Tailscale 作为中继。
碎碎念:
- VPN 能直接提供网络路由,带有跳板机的不行
- Tailscale 申请两个 auth-key,分别给 windows Tailscale cli 和 mac 代理客户端使用
- 不合规,真的不合规
Tailscale 官方说明了与其他 VPN 共存的限制。
样例
surge 有点摆烂连 vless 都不支持,但我用的比较久习惯了配置也熟悉,等 apple native clash 稳定再切
👇 surge 配置样例可以让不同设备选择对应的 tailscale 进行中继。
[Proxy]
Work_lan = ss, 192.xxx.xxx.xxx, xxxx, encrypt-method=2022-blake3-aes-256-gcm, password=""
Work_wan = ss, 110.xxx.xxx.xxx, xxxx, encrypt-method=2022-blake3-aes-256-gcm, password="", underlying-proxy=Tailnets
Tailnet-iPhone = tailscale, section-name=tailnet-ios //!REQUIREMENT "DEVICE_NAME=='iPhone'"
Tailnet-MacBook = tailscale, section-name=tailnet-mac //!REQUIREMENT "DEVICE_NAME=='macbook'"
Tailnet-Mac-mini = tailscale, section-name=tailnet-mac-mini //!REQUIREMENT "DEVICE_NAME=='mac-mini'"
[Proxy Group]
Tailnets = select, include-all-proxies=true, policy-regex-filter=^Tailnet-
[Tailscale tailnet-mac]
auth-key =
hostname = surge-mac
[Tailscale tailnet-mac-mini]
auth-key =
hostname = surge-mac-mini
[Tailscale tailnet-ios]
auth-key =
hostname = surge-ios
相关文档:
Tailscale: CLI 配置(tailscale up) ,Auth key 的生成与使用Surge: 链式代理 ,TailscaleClash: 链式代理 ,Tailscale