我的 Windows 计算机的 IP 地址是 -172.18.16.1
而我的 Ubuntu WSL 发行版是172.18.28.97
。我的发行版的名称服务器设置为 Windows 主机。我可以通过读取文件来验证这一点/etc/resolv.conf
:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.18.16.1
nslook
当我使用for进行查找时registry.npmjs.org
,得到以下结果:
Server: 172.18.16.1
Address: 172.18.16.1#53
Non-authoritative answer:
Name: registry.npmjs.org
Address: 104.16.23.35
Name: registry.npmjs.org
Address: 104.16.17.35
Name: registry.npmjs.org
Address: 104.16.16.35
Name: registry.npmjs.org
Address: 104.16.26.35
Name: registry.npmjs.org
Address: 104.16.25.35
Name: registry.npmjs.org
Address: 104.16.18.35
Name: registry.npmjs.org
Address: 104.16.22.35
Name: registry.npmjs.org
Address: 104.16.19.35
Name: registry.npmjs.org
Address: 104.16.21.35
Name: registry.npmjs.org
Address: 104.16.20.35
Name: registry.npmjs.org
Address: 104.16.27.35
Name: registry.npmjs.org
Address: 104.16.24.35
Name: bayan.ns.cloudflare.com
Address: 108.162.193.72
Name: bayan.ns.cloudflare.com
Address: 172.64.33.72
Name: bayan.ns.cloudflare.com
Address: 173.245.59.72
Name: sandy.ns.cloudflare.com
Address: 172.64.32.219
Name: sandy.ns.cloudflare.com
Address: 173.245.58.219
Name: sandy.ns.cloudflare.com
Address: 108.162.192.219
Name: bayan.ns.cloudflare.com
Address: 2803:f800:50::6ca2:c148
Name: bayan.ns.cloudflare.com
Address: 2a06:98c1:50::ac40:2148
Name: bayan.ns.cloudflare.com
Address: 2606:4700:58::adf5:3b48
Name: registry.npmjs.org
Address: 2606:4700::6810:1b23
Name: registry.npmjs.org
Address: 2606:4700::6810:1123
Name: registry.npmjs.org
Address: 2606:4700::6810:1823
Name: registry.npmjs.org
Address: 2606:4700::6810:1923
Name: registry.npmjs.org
Address: 2606:4700::6810:1a23
Name: registry.npmjs.org
Address: 2606:4700::6810:1723
Name: registry.npmjs.org
Address: 2606:4700::6810:1523
Name: registry.npmjs.org
Address: 2606:4700::6810:1223
Name: registry.npmjs.org
Address: 2606:4700::6810:1423
Name: registry.npmjs.org
Address: 2606:4700::6810:1023
Name: registry.npmjs.org
Address: 2606:4700::6810:1323
Name: registry.npmjs.org
Address: 2606:4700::6810:1623
Name: bayan.ns.cloudflare.com
Address: 172.64.33.72
Name: bayan.ns.cloudflare.com
Address: 173.245.59.72
Name: bayan.ns.cloudflare.com
Address: 108.162.193.72
当我使用 Windows 主机上的相同命令进行查找时,我得到了完全不同的响应:
Server: UnKnown
Address: 192.168.0.1
Non-authoritative answer:
Name: registry.npmjs.org
Addresses:
2606:4700::6810:1123
2606:4700::6810:1623
2606:4700::6810:1323
2606:4700::6810:1423
2606:4700::6810:1b23
2606:4700::6810:1923
2606:4700::6810:1a23
2606:4700::6810:1523
2606:4700::6810:1723
2606:4700::6810:1023
2606:4700::6810:1223
2606:4700::6810:1823
104.16.21.35
104.16.23.35
104.16.26.35
104.16.24.35
104.16.27.35
104.16.19.35
104.16.22.35
104.16.25.35
104.16.18.35
104.16.20.35
104.16.17.35
104.16.16.35
这导致我的 npm 安装在 WSL 内部中断,因为它返回像bayan.ns.cloudflare.com
和这样的域名的 IP 地址sandy.ns.cloudflare.com
。
我使用刷新了 Windows DNS ipconfig /flushdns
,但这并不能解决问题。我该怎么做才能解决这个问题?