文档/故障排查7 分钟

连接与运行时错误

解决服务启动失败、配置错误、TUN 问题、没有握手以及 DNS 警告。

完成后你将得到

wantasticd status 显示 Connected,且设备处于 Online 状态。

开始之前

  • 设备上的 root 或管理员权限。
  • 服务日志(参见 故障排查:从这里开始 → 收集日志)。

如何阅读日志

  • 以 "Failed to load configuration:" 或 "Failed to start agent:" 开头的行会使服务停止,随后服务管理器每 5 秒重启一次服务。
  • 正常启动以 "Wantastic agent started successfully" 结束。
  • 每 30 秒出现一次 "Device health check failed",表示代理在运行,但隧道没有流量通过。
  • P2P、端口映射和 DNS 提示大多只是信息性的。

检查要点

  1. 1服务循环重启:读取第一条 "Failed to …" 行,并在下文中查找。最常见的原因是配置为空。
  2. 2服务在运行但没有握手:放行出站 UDP 51820,然后检查时钟。
  3. 3握手正常但无法访问某个对端:检查 Topology 中的组链接。
失败:设备未认领
$ sudo journalctl -u wantasticd -n 3 --no-pager
wantasticd[812]: Failed to load configuration: validate config: private key required1
systemd[1]: wantasticd.service: Scheduled restart job, restart counter is at 14.
  1. 1尚未认领
服务以空配置启动并循环重启。
已修复:认领后重启
$ sudo wantasticd genkey
Device claimed. Configuration saved to /etc/wantastic/config.conf1
$ sudo systemctl restart wantasticd
wantasticd[901]: Wantastic agent started successfully
  1. 1按 Ctrl+C
使用 genkey 认领设备,按 Ctrl+C,然后重启服务。

速查表

错误最简单的修复方法
Config not found at … / private key required使用 genkey 认领,然后重启。
server public key … / server endpoint required删除配置,重新认领。
failed to resolve endpoint <host>修复 DNS;服务会自动重试。
/dev/net/tun does not exist安装 kmod-tun 或加载 tun 模块。
operation not permitted以 root 身份运行或添加 NET_ADMIN。
Device health check failed放行 UDP 51820;校正时钟。
the running daemon is older than this CLI…重启服务。
DNS: tunnel DNS not written (…)设置 WANTASTIC_DNS_MODE=off。

验证结果

wantasticd status 显示 Connected。
wantasticd peers 显示 (server),且握手时间在几秒之前。

错误与解决方法

connect 找不到配置。Config not found at <cfg>. Run `wantasticd genkey --out <key>` to create a claim key and wait for claim, or pass --wait-claim with an existing key.wantasticd connect
原因

设备从未认领过,或配置位于其他位置。

解决方法

使用 genkey 认领设备,然后重启服务。

Shellbash
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: 日志中出现 "Wantastic agent started successfully"。
安装后服务立即失败。Failed to load configuration: validate config: private key requiredwantasticd 日志
原因

设备尚未认领,因此配置为空。

解决方法

使用 genkey 认领设备,按 Ctrl+C,然后重启服务。

Shellbash
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: wantasticd status 显示 Connected。
配置缺少中心节点密钥。Failed to load configuration: validate config: server public key requiredwantasticd 日志
原因

配置不完整,或被手动编辑过。

解决方法

移走损坏的配置并重新认领设备。

Shellbash
sudo mv /etc/wantastic/config.conf /etc/wantastic/config.conf.bad
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: 服务启动。
中心节点密钥无效。Failed to load configuration: validate config: server public key must be a base64-encoded 32-byte WireGuard keywantasticd 日志
原因

配置只是占位内容(例如 Windows 登录失败后),或密钥在复制粘贴时损坏。

解决方法

移走损坏的配置并重新注册。在 Windows 上,使用新令牌登录。

Shellbash
sudo mv /etc/wantastic/config.conf /etc/wantastic/config.conf.bad
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: 服务启动。
配置中没有端点。Failed to load configuration: validate config: server endpoint requiredwantasticd 日志
原因

配置不完整。

解决方法

移走损坏的配置并重新认领设备。

Shellbash
sudo mv /etc/wantastic/config.conf /etc/wantastic/config.conf.bad
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: 服务启动。
启动时无法解析中心节点主机名。Failed to load configuration: validate config: failed to resolve endpoint <host>: …wantasticd 日志
原因

启动时 DNS 尚未就绪,或解析器故障("no IP addresses found for hostname")。

解决方法

检查 DNS。服务会自动重试。

Shellbash
nslookup wg.wantastic.app
sudo systemctl restart wantasticd
验证: 日志中出现 "WireGuard device up. Peer endpoint: …"。
无法创建隧道接口。Failed to start agent: create device: create tun: CreateTUN("wantastic0") failed; /dev/net/tun does not existwantasticd 日志
原因

缺少 TUN 内核模块(OpenWrt 未安装 kmod-tun),或容器中没有 /dev/net/tun。

解决方法

安装或加载 TUN,然后重启服务。

Shellbash
opkg update && opkg install kmod-tun   # OpenWrt
sudo modprobe tun                       # Linux
docker run --device /dev/net/tun --cap-add NET_ADMIN …   # Docker
验证: 日志中出现 "Created TUN interface: wantastic0"。
接口或路由出现权限错误。operation not permittedwantasticd 日志
原因

wantasticd 未以 root 身份运行,或容器没有 NET_ADMIN 权限。

解决方法

使用已安装的服务(它以 root 身份运行),或为容器添加 --cap-add NET_ADMIN。

Shellbash
sudo systemctl restart wantasticd
验证: 服务启动。
启动重试次数已用完。failed to start agent after 10 attempts: …wantasticd 日志
原因

另一个错误反复出现。冒号后面的文字才是真正的原因。

解决方法

在此列表中查找冒号后面的文字,修复后重启服务。

验证: 服务启动。
监听端口被占用。Port N in use, using random portwantasticd 日志
原因

另一个程序占用了该端口。"Port %d in use, retrying with port %d..." 含义相同,仅为提示信息。

解决方法

无需操作。

验证: 握手正常。
隧道中没有对端。WARNING: No peers configured in WireGuard device!wantasticd 日志
原因

配置中没有 [Peer] 部分。

解决方法

移走配置并重新认领设备。

Shellbash
sudo mv /etc/wantastic/config.conf /etc/wantastic/config.conf.bad
sudo wantasticd genkey
# after "Device claimed": press Ctrl+C, then:
sudo systemctl restart wantasticd
验证: wantasticd peers 列出 (server)。
健康检查持续失败。Device health check failed: …wantasticd 日志(每 30 秒)
原因

与中心节点没有握手:出站 UDP 51820 被阻止、时钟错误或 MTU 过大。

解决方法

在上游防火墙上放行出站 UDP 51820,并校正时钟。

Shellbash
sudo timedatectl set-ntp true
wantasticd peers
验证: wantasticd peers 显示握手时间在几秒之前。
本地控制端口失败。IPC API Error: failed to find open portwantasticd 日志
原因

端口 127.0.0.1:9034 及后续端口均被占用。"Warning: failed to start local IPC API" 和 "IPC API Error binding to …, trying next port..." 与此相关。

解决方法

停止占用该端口的程序,或使用 WTC_IPC_PORT 设置其他端口。

Shellbash
sudo ss -ltnp | grep 9034
验证: wantasticd status 正常工作。
CLI 版本比服务新。the running daemon is older than this CLI and has no /api/…; restart it to load the installed version (sudo systemctl restart wantasticd)wantasticd status / peers / ping
原因

二进制文件已更新,但服务仍在运行旧版本。

解决方法

重启服务。

Shellbash
sudo systemctl restart wantasticd
验证: wantasticd status 显示新版本。
CLI 无法与服务通信。daemon returned HTTP N: …wantasticd CLI
原因

本地控制 API 失败。"decode daemon response" 情况类似。

解决方法

重启服务后重试。

Shellbash
sudo systemctl restart wantasticd
验证: wantasticd status 正常工作。
对端一直走中继。direct handshake timeoutwantasticd 日志
原因

NAT 阻止了直连路径。"promotion queue full"、"gateway does not answer NAT-PMP"、"no UPnP internet gateway found" 和 "router's external address is not public (CGNAT)" 同样无害。

解决方法

无需操作,中继可以正常工作。如需直连路径,请在路由器上启用 UPnP 或 NAT-PMP。

验证: 流量正常通过。
本地访问找不到局域网。enable local access: no directly connected private IPv4 LAN subnet foundwantasticd (--allow-local-access)
原因

该设备没有私有 IPv4 局域网。

解决方法

在此设备上使用 --allow-local-access=false 关闭该选项。

验证: 重启后不再报错。
macOS 或 Windows 上的本地访问。automatic local-access subnet routing is not supported on macOS yetwantasticd (--allow-local-access)
原因

此功能仅适用于 Linux 和 OpenWrt(Windows 显示 "… on Windows yet")。

解决方法

使用 Linux 或 OpenWrt 设备作为局域网网关。

验证: 通过 Linux 或 OpenWrt 设备的本地访问正常工作。
伪装(masquerade)规则失败。iptables masquerade on <if>: …wantasticd (--allow-local-access)
原因

缺少 iptables。

解决方法

安装 iptables。

Shellbash
sudo apt-get install -y iptables
opkg install iptables-nft   # OpenWrt
验证: 本地访问正常工作。
无法启用转发。enable forwarding: …wantasticd (--allow-local-access)
原因

系统设置为只读(例如在容器中)。

解决方法

在宿主机上启用 IP 转发。

Shellbash
sudo sysctl -w net.ipv4.ip_forward=1
验证: 本地访问正常工作。
本地访问设备过多。too many tenant local-access advertiserswantasticd (--allow-local-access)
原因

你的账号中共享局域网的设备过多。

解决方法

在不需要的设备上关闭 --allow-local-access。

验证: 错误消失。
无法写入 DNS。DNS: tunnel DNS not written (…)wantasticd 日志
原因

另一个程序在管理 DNS。相关消息:"write <f>: read-only filesystem; remount it read-write or manage DNS through the platform resolver"、"<x> owns /etc/resolv.conf; DNS cannot be changed safely"、"<if> is not managed by NetworkManager"。

解决方法

让系统管理 DNS:为该服务设置 WANTASTIC_DNS_MODE=off。

Shellbash
sudo mkdir -p /etc/systemd/system/wantasticd.service.d
printf '[Service]\nEnvironment=WANTASTIC_DNS_MODE=off\n' | sudo tee /etc/systemd/system/wantasticd.service.d/dns.conf
sudo systemctl daemon-reload && sudo systemctl restart wantasticd
验证: 重启后不再出现 DNS 警告。
更新检查警告。Update check failed; will retry in an hour: …wantasticd 日志
原因

设备无法访问 get.wantastic.app。隧道仍正常工作。

解决方法

允许访问 get.wantastic.app 的 HTTPS。

Shellbash
curl -I https://get.wantastic.app/latest
验证: 下一次每小时检查时不再出现警告。
出现两个隧道,或出现 wantastic1 接口。ip link / wantasticd 日志
原因

genkey 或 login 仍在前台与服务同时运行。

解决方法

在 genkey 窗口中按 Ctrl+C,然后重启服务。

Shellbash
pgrep -a wantasticd
sudo systemctl restart wantasticd
验证: 只有一个 wantasticd 进程和一个 wantastic0 接口。

继续阅读

仍然无法解决?

请通过邮件发送设备名称、平台和完整的错误文本。切勿发送令牌、密钥或密码。

hello@wantastic.app