几周前,WSL 突然无法访问任何 IP 地址,也无法解析任何域名。甚至连内网 IP 都无法访问。
>lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
❯ neofetch
.-/+oossssoo+/-. klewis@NOTEBOOK-KLEWIS
`:+ssssssssssssssssss+:` ----------------------
-+ssssssssssssssssssyyssss+- OS: Ubuntu 20.04.1 LTS on Windows 10 x86_64
.ossssssssssssssssssdMMMNysssso. Kernel: 5.4.72-microsoft-standard-WSL2
/ssssssssssshdmmNNmmyNMMMMhssssss/ Uptime: 1 hour, 20 mins
+ssssssssshmydMMMMMMMNddddyssssssss+ Packages: 1405 (dpkg)
/sssssssshNMMMyhhyyyyhmNMMMNhssssssss/ Shell: zsh 5.8
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Theme: Adwaita [GTK3]
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Icons: Adwaita [GTK3]
ossyNMMMNyMMhsssssssssssssshmmmhssssssso Terminal: Windows Terminal
ossyNMMMNyMMhsssssssssssssshmmmhssssssso CPU: Intel i7-7820HK (8) @ 2.903GHz
+sssshhhyNMMNyssssssssssssyNMMMysssssss+ Memory: 968MiB / 5942MiB
.ssssssssdMMMNhsssssssssshNMMMdssssssss. Font: Cantarell 11 [GTK3]
/sssssssshNMMMyhhyyyyhdNMMMNhssssssss/
+sssssssssdmydMMMMMMMMddddyssssssss+
/ssssssssssshdmNNNNmyNMMMMhssssss/
.ossssssssssssssssssdMMMNysssso.
-+sssssssssssssssssyyyssss+-
`:+ssssssssssssssssss+:`
.-/+oossssoo+/-.
无线网络
❯ neofetch
.., klewis@LAPTOP-FLQBDPP8
....,,:;+ccllll ----------------------
...,,+:; cllllllllllllllllll OS: Pengwin on Windows 10 x86_64
,cclllllllllll lllllllllllllllllll Kernel: 5.4.72-microsoft-standard-WSL2
llllllllllllll lllllllllllllllllll Uptime: 30 mins
llllllllllllll lllllllllllllllllll Packages: 353 (dpkg)
llllllllllllll lllllllllllllllllll Shell: bash 5.1.4
llllllllllllll lllllllllllllllllll Terminal: Windows Terminal
llllllllllllll lllllllllllllllllll CPU: Intel i7-10750H (12) @ 2.592GHz
Memory: 106MiB / 25464MiB
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
llllllllllllll lllllllllllllllllll
`'ccllllllllll lllllllllllllllllll
`' \*:: :ccllllllllllllllll
````''*::cll
``
❯ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.106.224 netmask 255.255.240.0 broadcast 172.25.111.255
inet6 fe80::215:5dff:fe6f:8b36 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:6f:8b:36 txqueuelen 1000 (Ethernet)
RX packets 3488 bytes 468708 (468.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 26 bytes 1842 (1.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
❯ ccat /etc/resolv.conf
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 9.9.9.9
❯ ccat /etc/wsl.conf
[user]
default=klewis
# Now make it look like this and save the file when you're done:
[automount]
root = /
options = "metadata"
[network]
generateResolvConf = false
❯ ping 127.0.0.1
ping: connect: Network is unreachable
❯ ping 192.168.0.1
ping: connect: Network is unreachable
❯ ping 8.8.8.8
ping: connect: Network is unreachable
❯ ping google.com
ping: google.com: Temporary failure in name resolution
❯ nslookup google.com 9.9.9.9
;; connection timed out; no servers could be reached
❯ ip route
default via 172.25.96.1 dev eth0
172.25.96.0/20 dev eth0 proto kernel scope link src 172.25.106.224
❯ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether da:4a:7c:75:0f:84 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether da:8a:00:5a:47:57 brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:6f:8b:36 brd ff:ff:ff:ff:ff:ff
inet 172.25.106.224/20 brd 172.25.111.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe6f:8b36/64 scope link
valid_lft forever preferred_lft forever
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
C:\> ipconfig
Ethernet adapter vEthernet (WSL):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #5
Physical Address. . . . . . . . . : 00-15-5D-3D-76-44
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::85c9:71dc:b691:4da2%63(Preferred)
IPv4 Address. . . . . . . . . . . : 172.25.96.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 1056970077
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-27-6E-E5-67-54-05-DB-FD-51-82
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
>sudo ip route add default via 192.168.16.1
Error: Nexthop has invalid gateway.
我查看了 GH,找到了对其他人有用的解决方案。我尝试过的方法:
-
netsh winsock reset netsh int ip reset all netsh winhttp reset proxy ipconfig /flushdns
删除 Hyper-V 虚拟适配器并重新启动以让 Windows 重建
将 Hyper-V 虚拟交换机管理器中的虚拟交换机连接位置从内部网络更改为外部网络
确保 %TEMP% 未被压缩
确保 %TEMP% 下没有文件或文件夹被压缩
确保没有防火墙正在运行
关闭 resolv.conf 的生成并将网关 9.9.9.9 和 8.8.8.8 添加到 resolv.conf
❯ ccat /etc/hosts
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1 localhost
127.0.1.1 LAPTOP-FLQBDPP8.localdomain LAPTOP-FLQBDPP8
192.168.0.174 host.docker.internal
192.168.0.174 gateway.docker.internal
127.0.0.1 kubernetes.docker.internal
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
答案1
从版本 19042.1052 开始,它又可以正常工作了,我这边没有任何变化。我不确定实际原因,但由于我无法再重现它,进一步的故障排除似乎毫无意义。