doggo 在 IPv6 环境下有超时错误
简单来说就是之前本来计划 DNS Client 使用 dog 的,但有个几年没发布的问题修复 Error [network]: No such host is known. (os error 11001) · Issue #9 · ogham/dog 使得我不得不寻找新的替代品。好在找到了它的后辈 doggo,但安装好随便一个运行就是错误 “context deadline exceeded”
为什么记录呢,当然是遇到了神奇的现象。
$ doggo baidu.com --debug
time=2025-12-01T21:31:55.184+08:00 level=DEBUG msg="LoadNameservers: Initial nameservers" nameservers=[]
time=2025-12-01T21:31:55.190+08:00 level=DEBUG msg="No user specified nameservers, falling back to system nameservers"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Loaded system nameservers" nameservers="[{Address:[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53 Type:udp} {Address:192.168.9.1:53 Type:udp} {Address:[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53 Type:udp} {Address:[fe80::a236:bcff:fe70:ce58]:53 Type:udp}]"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="initiating UDP resolver"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="initiating UDP resolver"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="initiating UDP resolver"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="initiating UDP resolver"
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[fe80::a236:bcff:fe70:ce58]:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=192.168.9.1:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=192.168.9.1:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[fe80::a236:bcff:fe70:ce58]:53
time=2025-12-01T21:31:55.198+08:00 level=DEBUG msg="Attempting to resolve" domain=baidu.com. ndots=0 nameserver=[2409:8a1e:6940:64b0:a236:bcff:fe70:ce58]:53
time=2025-12-01T21:32:00.198+08:00 level=ERROR msg="Error looking up DNS records" error="context deadline exceeded"至于 dog 则是
$ dog baidu.com
Error [network]: No such host is known. (os error 11001)从日志中看,这里有几个问题
- DNS 服务器重复
- 查询无结果提示超时
查了些 issue 说和 cgo、IPv6 有关,没有有效结论
- Only works when I explicitly set
@8.8.8.8? · Issue #144 · mr-karan/doggo - “context deadline exceeded” - Continuous delay when running with (broken?) DNS settings · Issue #289 · fastly/cli
在我的环境中,当手动指定 DNS 服务器(doggo example.com "@192.168.9.1")是好了,说明不是网络问题。我的互联网访问也很正常,说明系统的 DNS 服务器(192.168.9.1)也是正常工作的。也不是 --timeout 调大等待时间能解决的,DNS 查询超过 200ms 都算不正常的了。
当我打算用 Wireshark 抓包看看问题在哪,一打开 Wireshark,程序它居然就表现正常了🤨
以及如果用 doggo should only query one resolver by default · Issue #35 · mr-karan/doggo 提出的新参数 --strategy=random 不断尝试也是有几率成功的,不成功的部分,使用的 DNS 是 nameserver=[fe80::a236:bcff:fe70:ce58]:53
这就很清楚了,正常来说因为每条链路中 Link-Local 地址互相不知道,也就允许有设备具有相同的地址,所以访问 IPv6 Link-Local Address fe80::/10 按 RFC 4007 (IPv6 Scoped Address Architecture) 所说需要添加网卡编号,像这样 fe80::ea6b:5574:68ac:fee4%4。而我刚好有多张网卡,实体的虚拟的,有线的无线的。
$ netsh interface ipv6 show route
Publish Type Met Prefix Idx Gateway/Interface Name
------- -------- --- ------------------------ --- ------------------------
No Manual 256 ::/0 4 fe80::a236:bcff:fe70:ce58
No System 256 ::1/128 1 Loopback Pseudo-Interface 1
No Manual 256 2409:8a1e:6940:64b0::/64 4 以太网
No System 256 2409:8a1e:6940:64b0::25c/128 4 以太网
No System 256 2409:8a1e:6940:64b0:1711:f510:7897:5e6/128 4 以太网
No System 256 2409:8a1e:6940:64b0:b8b3:85b5:fc2c:c56d/128 4 以太网
No System 256 fe80::/64 4 以太网
No System 256 fe80::/64 14 蓝牙网络连接
No System 256 fe80::/64 66 vEthernet (Default Switch)
No System 256 fe80::/64 17 WLAN
No System 256 fe80::/64 2 WLAN 2
No System 256 fe80::4b8a:6eea:acd3:8288/128 14 蓝牙网络连接
No System 256 fe80::80eb:7b7d:baf0:2161/128 66 vEthernet (Default Switch)
No System 256 fe80::8cc3:1d6c:be27:f9d9/128 2 WLAN 2
No System 256 fe80::e3e2:5ac3:e885:1d4c/128 17 WLAN
No System 256 fe80::ea6b:5574:68ac:fee4/128 4 以太网
No System 256 ff00::/8 1 Loopback Pseudo-Interface 1
No System 256 ff00::/8 4 以太网
No System 256 ff00::/8 14 蓝牙网络连接
No System 256 ff00::/8 66 vEthernet (Default Switch)
No System 256 ff00::/8 17 WLAN
No System 256 ff00::/8 2 WLAN 2
$ route print -6
===========================================================================
Interface List
66...00 15 5d 70 ce 58 ......Hyper-V Virtual Ethernet Adapter
4...10 ff e0 81 a7 2e ......Realtek PCIe 2.5GbE Family Controller
2...46 fa 66 12 05 07 ......MediaTek Wi-Fi 7 MT7925 Wireless LAN Card #2
7...46 fa 66 12 75 77 ......MediaTek Wi-Fi 7 MT7925 Wireless LAN Card #4
17...44 fa 66 12 25 27 ......MediaTek Wi-Fi 7 MT7925 Wireless LAN Card
14...44 fa 66 12 25 28 ......Bluetooth Device (Personal Area Network)
1...........................Software Loopback Interface 1
===========================================================================
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination Gateway
4 281 ::/0 fe80::a236:bcff:fe70:ce58
1 331 ::1/128 On-link
4 281 2409:8a1e:6940:64b0::/64 On-link
4 281 2409:8a1e:6940:64b0::25c/128
On-link
4 281 2409:8a1e:6940:64b0:1711:f510:7897:5e6/128
On-link
4 281 2409:8a1e:6940:64b0:b8b3:85b5:fc2c:c56d/128
On-link
4 281 fe80::/64 On-link
66 271 fe80::/64 On-link
66 271 fe80::80eb:7b7d:baf0:2161/128
On-link
4 281 fe80::ea6b:5574:68ac:fee4/128
On-link
1 331 ff00::/8 On-link
4 281 ff00::/8 On-link
66 271 ff00::/8 On-link这里还有个 未解之谜 ,为什么一张 MediaTek Wi-Fi 7 MT7925 Wireless LAN Card,在系统里能显示为 3 个 MAC 地址都不同的网卡
各家 Metrics 都是 256, 系统随机选择了出口。比如去往主路由器的地址可以走以太网,也可以走完全没有网络连接的 vEthernet (Default Switch),从 Wireshark 抓包结果也能证实这一点。
所以会造成如此离谱的结果,在此亦有解释
- Why is there a percent sign ’%’ in the IPv6 address? - Super User
- Always On VPN and Interface Metrics | Richard M. Hicks Consulting, Inc.
$ ping fe80::a236:bcff:fe70:ce58
正在 Ping fe80::a236:bcff:fe70:ce58 具有 32 字节的数据:
来自 fe80::a236:bcff:fe70:ce58 的回复: 时间<1ms
无法访问目标主机。
无法访问目标主机。
无法访问目标主机。
fe80::a236:bcff:fe70:ce58 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 1,丢失 = 3 (75% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms这个 vEthernet (Default Switch) 是 Hyper-V (Docker Desktop)创建的虚拟网卡;
另一边由 WSL2 创建的 vEthernet (FSE HostVnic) 不会造成这个问题
解决方式:
- 立刻生效的就是禁用 “vEthernet (Default Switch)” 的 Internet 协议版本 6 (TCP/IPv6),以及关闭其他无关网卡
- 我关闭了 启用或关闭 Windows 功能(Win+R 中输入 optionalfeatures)中的容器和 Hyper-V,重启电脑后不再重新生成 vEthernet (Default Switch),没有别的路可走也就正常了
- 手动提升跃点数
netsh interface ipv6 set interface interface="以太网" metric=10