解决 Wireguard 互联时 No route to host 的问题

Mar 07, 2025 • 预计阅读时间 1 分钟

在某些复杂的网络环境下,仅使用简单的配置可能会遇到 No route to host 的问题。

具体表现是使用 traceroute 命令无法访问到目标 IP(10.1.1.5 是另一台 Wireguard Peer 设备的地址)。

$ traceroute 10.1.1.5
traceroute to 10.1.1.5 (10.1.1.5), 30 hops max, 60 byte packets
 1  Workstation (192.168.1.2)  3061.720 ms !H  3061.660 ms !H  3061.644 ms !H

解决方法是在 Wireguard 配置文件中添加 Table 选项。

[Interface]
PrivateKey = cJOQ7OfmkIoLS3BzmE+kNhJ950TZXsIkROiEi8kjPoK=
Address = 10.1.1.2/32
MTU = 1280
Table = 200
PostUp   = /sbin/ip rule add to 10.1.1.0/24 table 200 priority 101
PostDown = /sbin/ip rule del to 10.1.1.0/24 table 200 priority 101
LinuxWireguard
版权声明:如果转发请带上本文链接和注明来源。

lvv.me

iOS/macOS Developer

使用 `withUnsafeContinuation` 代替 `withCheckedContinuation` 避免在 iOS 18 中发生崩溃

在 macOS 上安装 clang-format