无法 ping npm 注册表 URLhttps://registry.npmjs.org/来自 Ubuntu WSL1。其余一切都可 ping 通。
以下是 WSL1 的终端输出 -
$ ping registry.npmjs.org
ping: registry.npmjs.org: Temporary failure in name resolution
$ ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=38.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=119 time=38.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=119 time=38.7 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 38.044/38.496/38.752/0.358 ms
$ ping google.com -c 3
PING google.com (142.250.71.46) 56(84) bytes of data.
64 bytes from maa03s35-in-f14.1e100.net (142.250.71.46): icmp_seq=1 ttl=119 time=45.4 ms
64 bytes from maa03s35-in-f14.1e100.net (142.250.71.46): icmp_seq=2 ttl=119 time=55.3 ms
64 bytes from maa03s35-in-f14.1e100.net (142.250.71.46): icmp_seq=3 ttl=119 time=46.3 ms
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 45.494/49.054/55.336/4.458 ms
这就是/etc/resolv.conf文件看起来像
$ cat /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 192.168.0.1
nameserver fec0:0:0:ffff::1
nameserver fec0:0:0:ffff::2
输出挖掘 registry.npmjs.org命令 -
$ dig registry.npmjs.org
; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> registry.npmjs.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54664
;; flags: qr rd ra; QUERY: 1, ANSWER: 12, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;registry.npmjs.org. IN A
;; ANSWER SECTION:
registry.npmjs.org. 189 IN A 104.16.23.35
registry.npmjs.org. 189 IN A 104.16.24.35
registry.npmjs.org. 189 IN A 104.16.25.35
registry.npmjs.org. 189 IN A 104.16.26.35
registry.npmjs.org. 189 IN A 104.16.27.35
registry.npmjs.org. 189 IN A 104.16.16.35
registry.npmjs.org. 189 IN A 104.16.17.35
registry.npmjs.org. 189 IN A 104.16.18.35
registry.npmjs.org. 189 IN A 104.16.19.35
registry.npmjs.org. 189 IN A 104.16.20.35
registry.npmjs.org. 189 IN A 104.16.21.35
registry.npmjs.org. 189 IN A 104.16.22.35
;; Query time: 41 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Wed Jun 23 16:51:32 IST 2021
;; MSG SIZE rcvd: 444
相同的 ping 在 CMD 和 Powershell 中工作正常。
如果我的帖子需要更新,请告诉我。提前谢谢您。