# wg-easy / WireGuard 组网运维记录 本文档记录无人直播栈当前采用的 WireGuard 中继方案,以及和 Neko、ShellCrash、Windows Mihomo/TUN 共存时的固定处理方式。 ## 当前拓扑 - 腾讯云 VPS:`129.204.21.129`,作为中国方向 WireGuard 中继。 - WireGuard 端口:`51820/udp`,云防火墙和系统防火墙都需要放行。 - Neko 主机:`10.88.0.2`。 - Windows 客户端:`10.88.0.6/32`。 - Neko Web:`http://10.88.0.2:9201/`,本地 LAN 和 WireGuard 网络都应能访问。 腾讯云仅负责中继内网段流量,不承载 ShellCrash 代理。Neko 容器内访问 Google/YouTube 仍走 Neko 主机上的 ShellCrash HTTP 代理。 ## 2026-06-02 生产校验 - wandaA:`wgeasy` 使用 `Endpoint = 129.204.21.129:51820`,`Address = 10.88.0.4/32`,`MTU = 1360`,`PersistentKeepalive = 25`;切回 `107.172.77.34:51820` 时未握手。 - wandaB:`wgeasy` 使用 `Endpoint = 129.204.21.129:51820`,`Address = 10.88.0.2/32`;到 `10.88.0.1` 的延迟约 25ms。 - Neko 访问优先级:WireGuard `10.88.0.0/24` 优先,frp 公网端口兜底,EasyTier `10.126.126.0/24` 作为备用运维链路。 ## 推荐参数 WireGuard peer 推荐: ```ini MTU = 1360 PersistentKeepalive = 25 Endpoint = 129.204.21.129:51820 ``` VPS 内核和链路优化: ```bash sysctl -w net.core.default_qdisc=fq sysctl -w net.ipv4.tcp_congestion_control=bbr sysctl -w net.core.rmem_max=2500000 sysctl -w net.core.wmem_max=2500000 iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu ``` ## Windows 与 Mihomo/TUN 共存 如果 Windows 上有 Mihomo、Clash、ShellCrash TUN 抢默认路由,WireGuard 的 VPS Endpoint 可能被送进代理出口,导致绕路和高延迟。必须给 VPS 公网 IP 加一条物理网关旁路路由: ```powershell route -p add 129.204.21.129 mask 255.255.255.255 192.168.2.1 metric 1 if 21 ``` 参数说明: - `129.204.21.129`:WireGuard VPS Endpoint。 - `192.168.2.1`:Windows 当前物理局域网网关。 - `if 21`:Windows 物理网卡 ifIndex,用 `Get-NetIPInterface -AddressFamily IPv4` 查看。 删除命令: ```powershell route delete 129.204.21.129 ``` ## Neko 黑屏和 NAT1TO1 Neko WebRTC 候选地址必须是访问端可达的地址。当前跨 WireGuard 访问时应设置: ```env NEKO_WEBRTC_NAT1TO1=10.88.0.2 NEKO_WEBRTC_EPR=52101-52199 NEKO_WEBRTC_TCPMUX=52301 NEKO_WEBRTC_UDPMUX=52301 ``` 不要把旧公网 IP 写入 `NEKO_WEBRTC_NAT1TO1`。源码已调整为:显式填入本机 WireGuard/Tailscale/EasyTier 地址时,Neko LAN watcher 不会再把它覆盖成物理 LAN IP;留空才自动选择物理 LAN IP。 ## Web 控制台导入 无人直播 Web 的「网络」模块支持导入 VPS 的 WireGuard `.conf`: - 配置会保存到 `config/wireguard/imports/.conf`。 - 返回结果会脱敏 `PrivateKey`、`PublicKey`、`PresharedKey`。 - 页面会生成 Windows Endpoint 旁路路由模板。 导入功能只做解析和保存,不直接执行系统级 `wg-quick` 或 Windows 隧道安装命令,避免从 Web 表单执行未审计的网络配置。 ## 旧 Endpoint 排障 旧 VPS Endpoint 只保留作排障记录。2026-06-02 校验时,wandaA 指向该端点无法握手,不应作为生产首选: ```ini Endpoint = 107.172.77.34:51820 ``` 只有确认旧 VPS 的 wg-easy 容器、UDP `51820` 入站、防火墙和客户端出口都正常后,才临时切换到该端点。同时删除 Windows 上指向腾讯云的持久路由,或改成旧 Endpoint 对应的物理旁路路由。