Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tailscale 组网 #201

Open
Bpazy opened this issue Sep 28, 2021 · 7 comments
Open

tailscale 组网 #201

Bpazy opened this issue Sep 28, 2021 · 7 comments
Labels
Wireguard 组网咯

Comments

@Bpazy
Copy link
Owner

Bpazy commented Sep 28, 2021

官网: https://tailscale.com/,威联通踩坑

@Bpazy
Copy link
Owner Author

Bpazy commented Sep 28, 2021

优势:

  • 支持根据主机名访问网内其他设备(通过 DNS 解析实现)
  • 支持 子网路由

劣势:

  • 免费版最多支持 20 个设备
  • 免费版子网路由最多支持 1 个

@Bpazy Bpazy added the Wireguard 组网咯 label Apr 14, 2022
@Bpazy
Copy link
Owner Author

Bpazy commented Jun 1, 2022

创建 Tailscale derper

详情: #219

@Bpazy
Copy link
Owner Author

Bpazy commented Jun 1, 2022

关于近期遇到了 subnets 不生效问题

近期遇到了 subnets 不生效的问题,导致服务挂了一堆,重新研读了官方文档: Subnet routers and traffic relay nodes
,发现其中有几个要点:

  1. 提供 subnet 服务的主机,需要携带 advertise-routes 参数启动,形如: sudo tailscale up --advertise-routes=192.168.31.0/24
  2. 需要使用 subnet 服务的主机,即外部机器需要通过 subnet 节点访问内网机器,需要携带 accept-routes 参数启动,形如: sudo tailscale up --accept-routes

2024.02.29 再次遇到问题

尝试上述方案无过后,在中转节点上执行 journalctl -fu tailscaled 命令查看 tailscaled 日志,发现正常接收到了远程的请求,但是转发不对,于是通过下面这个命令解决:

iptables -t nat -A POSTROUTING -j MASQUERADE

但这又导致机器无法直接访问外部网络了,推测是 iptables 被搞乱了,最近安装过 microk8s,可能有相关性,于是导出所有规则:

sudo iptables-save > myrule

编辑文件,删除其中所有含有 k8s, kube, cali 关键词的行,这些都和 k8s 有关。然后写会规则:

sudo iptables-restore < myrule

现在一切都 ok 了。

@Bpazy
Copy link
Owner Author

Bpazy commented Jun 1, 2022

Please restart system service

今日在 Win11 系统上,遇到了 Tailscale 不能正常启动的情况,提示 please restart system service, 但是实际操作又会发现重启 Tailscale 服务也不行,后来使用该方法解决了问题: tailscale/tailscale#2031 (comment)

@Bpazy
Copy link
Owner Author

Bpazy commented Nov 30, 2022

Tailscale 导致威联通根目录被占满

威联通根目录是 RAMdisk,并且只有 400M,根目录满了之后就无法正常运行了,必须重启机器才行。

Tailscale 会不断写日志到 /var/lib/tailscale 目录下导致了这个问题,给官方提了 issue 反馈: tailscale/tailscale-qpkg#57

@Bpazy
Copy link
Owner Author

Bpazy commented Mar 2, 2023

Clash 全局模式与 Tailscale 不兼容问题

参考我的解决方案: https://github.com/Dreamacro/clash/issues/2251#issuecomment-1289386440

今天抽空对 tailscaled, tailscale 的源码进行了调试,发现当开启 Clash Tun 的时候,tailscaled 因为连接不上这两个域名导致始终无法成功启动:

controlplane.tailscale.com
log.tailscale.io
所以我通过将这两个域名添加到 fake-ip-filter 列表中解决了问题:

  dns:
    enable: true
    enhanced-mode: fake-ip
    nameserver:
      - 114.114.114.114
    fallback: []
    fake-ip-filter:
      # 省略了部分配置
      - controlplane.tailscale.com
      - log.tailscale.io

同时注意,Clash for Windows 不会读取 user profile 中的 dns 模块,所以上面的这段代码要写在 Clash for Windows 的 Mixin 配置中:
image

我的完整 Mixin:

mixin: # object
  dns:
    enable: true
    enhanced-mode: fake-ip
    nameserver:
      - 114.114.114.114
      - 223.5.5.5
      - 8.8.8.8
    fallback: []
    fake-ip-filter:
      - +.stun.*.*
      - +.stun.*.*.*
      - +.stun.*.*.*.*
      - +.stun.*.*.*.*.*
      - "*.n.n.srv.nintendo.net"
      - +.stun.playstation.net
      - xbox.*.*.microsoft.com
      - "*.*.xboxlive.com"
      - "*.msftncsi.com"
      - "*.msftconnecttest.com"
      - WORKGROUP
      - controlplane.tailscale.com
      - log.tailscale.io
  tun:
    enable: true
    stack: gvisor
    auto-route: true
    auto-detect-interface: true
    dns-hijack:
      - any:53
另外如果使用了 Tailscale derper,记得将 Access Controls 中配置的 HostName 也增加到 fake-ip-filter 中。

以上测试基于:

Clash for Windows v0.20.6
Clash Core 2022.08.26 Premium (56523)
Tailscale 1.24.2
Tailscale 1.32.1
Tailscale a6b77bcb008f14c8356b6618904b11b209c5e156

@Bpazy
Copy link
Owner Author

Bpazy commented Mar 18, 2024

局域网内有多个 subnet 时局域网无法互联

比如 A, B 都在 LAN1 下,两者都开启了 subnet,并且 B 启动时指定了 --accept-routes 参数,那么此时局域网的其他机器是无法 ping 通 B 机器的。

究其原因,参考官方文档: How to prioritize LAN traffic with overlapping subnet routes (如何优先考虑具有重叠子网路由的 LAN 流量)

解决方案也很简单,让子网的优先级比 tailscale 更高即可:

ip rule add to 192.168.31.0/24 priority 2500 lookup main

不过上面的命令只能临时生效,想要机器重启也能生效则需要更改 netplan 的设置,比如我的配置:

ziyuan@nhan-ubuntu:/etc/netplan$ pwd
/etc/netplan
ziyuan@nhan-ubuntu:/etc/netplan$ cat 50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        ens3:
            dhcp4: true
            routing-policy:
                - from: 0.0.0.0/0
                  to: 192.168.31.0/24
                  priority: 2500
    version: 2

如果是 Debian 没有 netplan,那更简单 vim /etc/network/interfaces:

auto lo
iface lo inet loopback

iface enp8s0 inet manual

auto vmbr0
iface vmbr0 inet static
        address 192.168.31.30/24
        gateway 192.168.31.1
        bridge_ports enp8s0
        bridge_stp off
        bridge_fd 0
        post-up ip rule add to 192.168.31.0/24 priority 2500 lookup main

iface wlp15s0 inet manual

主要是其中的 post-up ip rule add to 192.168.31.0/24 priority 2500 lookup main,其他配置不要抄我作业。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wireguard 组网咯
Projects
None yet
Development

No branches or pull requests

1 participant