我在 Windows 10 中运行 WSL2、Ubuntu 22。当我nslookup
不连接 VPN 时,我得到以下结果(请注意,所有答案都是 FQDN google.com 的不同 IP 地址)。
daniel@DESKTOP-6M0RKK1:~
⤷ nslookup google.com
Server: 172.23.144.1
Address: 172.23.144.1#53
Non-authoritative answer:
Name: google.com
Address: 142.251.116.139
Name: google.com
Address: 142.251.116.102
Name: google.com
Address: 142.251.116.100
Name: google.com
Address: 142.251.116.113
Name: google.com
Address: 142.251.116.101
Name: google.com
Address: 142.251.116.138
但是,当我连接到 VPN 时,答案会发生变化,还会显示一些 DNS 服务器的 IP 地址的答案。
daniel@DESKTOP-6M0RKK1:~
⤷ nslookup google.com
Server: 172.23.144.1
Address: 172.23.144.1#53
Non-authoritative answer:
Name: google.com
Address: 142.251.135.110
Name: ns1.google.com
Address: 216.239.32.10
Name: ns2.google.com
Address: 216.239.34.10
Name: ns3.google.com
Address: 216.239.36.10
Name: ns4.google.com
Address: 216.239.38.10
我使用 展示了示例google.com
,但我尝试查找的任何 URL 都会发生这种情况。这是症状,真正的问题是其他命令(如curl
)在请求时使用解析列表中的随机 IP(?),有时请求会转到第一个 IP,运行成功,但其他时候请求最终被发送到 DNS 服务器而不是正确的 IP。
现在我不知道在哪里检查问题。我不知道问题是 WSL 上的配置错误,还是 Windows 网络上的配置错误,或者是 VPN 的 DNS 服务器上的配置错误。所以任何形式的帮助都非常感谢。
附言:在连接 VPN 的情况下,Windows 的解析直接正常工作。问题仅在 WSL 内部。
编辑:添加调试输出。当查找使用 WSL 接口网关作为名称服务器时,看起来Authority
和Additional
记录正在合并。Answers
nslookup -debug google.com
来自 WSL2 系统的输出。
此命令应使用 WSL 网关作为名称服务器,并将请求发送到 VPN 名称服务器。
daniel@DESKTOP-6M0RKK1:~
⤷ nslookup -debug google.com
Server: 172.23.144.1
Address: 172.23.144.1#53
------------
QUESTIONS:
google.com, type = A, class = IN
ANSWERS:
-> google.com
internet address = 142.251.133.174
ttl = 0
-> ns1.google.com
internet address = 216.239.32.10
ttl = 0
-> ns2.google.com
internet address = 216.239.34.10
ttl = 0
-> ns3.google.com
internet address = 216.239.36.10
ttl = 0
-> ns4.google.com
internet address = 216.239.38.10
ttl = 0
AUTHORITY RECORDS:
ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name: google.com
Address: 142.251.133.174
Name: ns1.google.com
Address: 216.239.32.10
Name: ns2.google.com
Address: 216.239.34.10
Name: ns3.google.com
Address: 216.239.36.10
Name: ns4.google.com
Address: 216.239.38.10
nslookup -debug google.com 10.0.24.151
来自 WSL2 系统的输出。
此命令应直接使用 VPN 名称服务器。
daniel@DESKTOP-6M0RKK1:~
⤷ nslookup -debug google.com 10.0.24.151
Server: 10.0.24.151
Address: 10.0.24.151#53
------------
QUESTIONS:
google.com, type = A, class = IN
ANSWERS:
-> google.com
internet address = 142.251.133.174
ttl = 227
AUTHORITY RECORDS:
-> google.com
nameserver = ns1.google.com.
ttl = 5636
-> google.com
nameserver = ns2.google.com.
ttl = 5636
-> google.com
nameserver = ns4.google.com.
ttl = 5636
-> google.com
nameserver = ns3.google.com.
ttl = 5636
ADDITIONAL RECORDS:
-> ns1.google.com
internet address = 216.239.32.10
ttl = 92272
-> ns2.google.com
internet address = 216.239.34.10
ttl = 92272
-> ns3.google.com
internet address = 216.239.36.10
ttl = 18575
-> ns4.google.com
internet address = 216.239.38.10
ttl = 18575
------------
Non-authoritative answer:
Name: google.com
Address: 142.251.133.174
来自 Windows的输出nslookup -d google.com
。
此命令应直接使用 VPN 名称服务器。输出已被删除,不显示与我工作的公司相关的名称。
PS C:\Users\danie> nslookup -d google.com
------------
Got answer:
HEADER:
opcode = QUERY, id = 1, rcode = NOERROR
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 7, additional = 7
QUESTIONS:
151.24.0.10.in-addr.arpa, type = PTR, class = IN
ANSWERS:
-> 151.24.0.10.in-addr.arpa
name = s2-<redacted>
ttl = 900 (15 mins)
AUTHORITY RECORDS:
-> 10.in-addr.arpa
nameserver = s17-<redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = s343-<redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = s2-<redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = s344-<redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = s1-<redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = <redacted>
ttl = 900 (15 mins)
-> 10.in-addr.arpa
nameserver = <redacted>
ttl = 900 (15 mins)
ADDITIONAL RECORDS:
-> s1-<redacted>
internet address = 10.0.16.253
ttl = 900 (15 mins)
-> <redacted>
internet address = 10.17.0.4
ttl = 900 (15 mins)
-> s17-<redacted>
internet address = 10.8.74.34
ttl = 900 (15 mins)
-> <redacted>
internet address = 10.58.0.240
ttl = 900 (15 mins)
-> s2-<redacted>
internet address = 10.0.24.151
ttl = 900 (15 mins)
-> s343-<redacted>
internet address = 10.0.29.143
ttl = 900 (15 mins)
-> s344-<redacted>
internet address = 10.0.29.144
ttl = 900 (15 mins)
------------
Server: s2-<redacted>
Address: 10.0.24.151
------------
Got answer:
HEADER:
opcode = QUERY, id = 2, rcode = NXDOMAIN
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 1, additional = 0
QUESTIONS:
google.com.<redated_internal_suffix>, type = A, class = IN
AUTHORITY RECORDS:
-> <redated_internal_suffix>
ttl = 900 (15 mins)
primary name server = s2-<redacted>.<redated_internal_suffix>
responsible mail addr = root.s2-<redacted>
serial = 2023071101
refresh = 86400 (1 day)
retry = 7200 (2 hours)
expire = 2592000 (30 days)
default TTL = 345600 (4 days)
------------
------------
Got answer:
HEADER:
opcode = QUERY, id = 3, rcode = NXDOMAIN
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 0, authority records = 1, additional = 0
QUESTIONS:
google.com.<redated_internal_suffix>, type = AAAA, class = IN
AUTHORITY RECORDS:
-> <redated_internal_suffix>
ttl = 900 (15 mins)
primary name server = s2-<redacted>
responsible mail addr = root.s2-<redacted>
serial = 2023071101
refresh = 86400 (1 day)
retry = 7200 (2 hours)
expire = 2592000 (30 days)
default TTL = 345600 (4 days)
------------
------------
Got answer:
HEADER:
opcode = QUERY, id = 4, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 4, additional = 8
QUESTIONS:
google.com, type = A, class = IN
ANSWERS:
-> google.com
internet address = 142.250.79.14
ttl = 23 (23 secs)
AUTHORITY RECORDS:
-> google.com
nameserver = ns2.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns4.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns3.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns1.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
ADDITIONAL RECORDS:
-> ns1.google.com
internet address = 216.239.32.10
ttl = 92711 (1 day 1 hour 45 mins 11 secs)
-> ns2.google.com
internet address = 216.239.34.10
ttl = 92711 (1 day 1 hour 45 mins 11 secs)
-> ns3.google.com
internet address = 216.239.36.10
ttl = 19014 (5 hours 16 mins 54 secs)
-> ns4.google.com
internet address = 216.239.38.10
ttl = 19014 (5 hours 16 mins 54 secs)
-> ns1.google.com
AAAA IPv6 address = 2001:4860:4802:32::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns2.google.com
AAAA IPv6 address = 2001:4860:4802:34::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns3.google.com
AAAA IPv6 address = 2001:4860:4802:36::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns4.google.com
AAAA IPv6 address = 2001:4860:4802:38::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
------------
Non-authoritative answer:
------------
Got answer:
HEADER:
opcode = QUERY, id = 5, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 4, additional = 8
QUESTIONS:
google.com, type = AAAA, class = IN
ANSWERS:
-> google.com
AAAA IPv6 address = 2800:3f0:4004:808::200e
ttl = 41 (41 secs)
AUTHORITY RECORDS:
-> google.com
nameserver = ns1.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns3.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns4.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
-> google.com
nameserver = ns2.google.com
ttl = 6075 (1 hour 41 mins 15 secs)
ADDITIONAL RECORDS:
-> ns1.google.com
internet address = 216.239.32.10
ttl = 92711 (1 day 1 hour 45 mins 11 secs)
-> ns2.google.com
internet address = 216.239.34.10
ttl = 92711 (1 day 1 hour 45 mins 11 secs)
-> ns3.google.com
internet address = 216.239.36.10
ttl = 19014 (5 hours 16 mins 54 secs)
-> ns4.google.com
internet address = 216.239.38.10
ttl = 19014 (5 hours 16 mins 54 secs)
-> ns1.google.com
AAAA IPv6 address = 2001:4860:4802:32::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns2.google.com
AAAA IPv6 address = 2001:4860:4802:34::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns3.google.com
AAAA IPv6 address = 2001:4860:4802:36::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
-> ns4.google.com
AAAA IPv6 address = 2001:4860:4802:38::a
ttl = 160225 (1 day 20 hours 30 mins 25 secs)
------------
Name: google.com
Addresses: 2800:3f0:4004:808::200e
142.250.79.14
编辑 2:看起来它与为 WSL 创建的内部 DNS 服务器的问题有关,该服务器是内部 Hyper-V DNS 服务器,即 Windows Internet 连接共享 (ICS)。
我在 WSL 的 GitHub 上发现了一个未解决的问题,很多人都在抱怨这个问题。