0

我是az login从我的 Windows 机器的 WSL 做的。然后它给出了一个错误:

Please ensure you have network connection. Error detail: HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries exceeded with url: /common/oauth2/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f401d135630>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

我希望这是一个 DNS 问题。所以我检查/etc/resolv.conf了 WSL:

# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
nameserver 192.168.1.1
nameserver fcc0:0:0:ffff::1
nameserver fcc0:0:0:ffff::2

192.168.1.1 是默认网关。

我尝试了一些命令的结果:

$ ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.                                                                                                                                          
64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=0.351 ms                                                                                                                                   
64 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=0.888 ms                                                                                                                                   
64 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=0.883 ms  

$ dig 192.168.1.1

; <<>> DiG 9.11.3-1ubuntu1.3-Ubuntu <<>> 192.168.1.1                                                                                                                                          
;; global options: +cmd                                                                                                                                                                       
;; connection timed out; no servers could be reached 

$ nslookup 192.168.1.1

;; connection timed out; no servers could be reached   

这些命令还提供指示问题的输出。

Ping google.com
dig google.com

所有这些命令(或其替代命令)都可以在 Windows 命令提示符下正常工作。

我在这里找到了解决方法

https://askubuntu.com/questions/91543/apt-get-update-fails-to-fetch-files-temporary-failure-resolving-error

它说我应该在 /etc/resolv.conf 中添加以下行。如果我这样尝试,它会起作用。

nameserver 192.168.1.1
nameserver 8.8.8.8 
nameserver fcc0:0:0:ffff::1
nameserver fcc0:0:0:ffff::2

在此之后,ping google.comanddig google.com工作正常。但我可以看到它用来解析的名称服务器是8.8.8.8.

如果我连接到 VPN,它会将我们自己的名称服务器添加到 /etc/resolv.conf 中,然后解析 URL 就没有问题了。VPN断开后,问题再次出现。

笔记:

以前没有这样的问题。昨天我们更改了路由器以使用新的 ISP 连接,然后出现问题。同一网络中的其他机器没有这个问题。

为什么会发生这种情况以及如何正确解决此 WSL 问题?

为什么我们网络中只有一台机器可以ping通,却不能挖到默认网关?

更新:

我可以看到路由表中有两个条目被标记为默认值:

 $ ip route show table all | grep default                                                                                

 none default via 192.168.0.1 dev wifi0 proto unspec metric 0                                                            
 none default via 192.168.1.1 dev eth6 proto unspec metric 0
4

0 回答 0