我正在尝试在办公室笔记本电脑上使用 WSL2 运行 Ubuntu。
问题:
当我尝试运行 apt-get update 或任何安装命令时,例如:apt-get install gcc,它总是以101: Network is unreachable
.
我迄今为止尝试过的解决方案:
防火墙
我最初的猜测是办公室防火墙可能阻止了连接,但快速 ping 检查后我发现它运行正常。此外,我还在 Chrome 中浏览了 URL,它没有任何问题。
$ ping 91.189.91.39 PING 91.189.91.39 (91.189.91.39) 56(84) bytes of data. 64 bytes from 91.189.91.39: icmp_seq=1 ttl=51 time=256 ms 64 bytes from 91.189.91.39: icmp_seq=2 ttl=51 time=256 ms ^C --- 91.189.91.39 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 255.540/255.757/255.975/0.217 ms
解析器配置文件问题。
我尝试将默认名称服务器更改为 8.8.8.8 并尝试使用其他 DNS 提供商,但问题并未得到解决。此外,由于 ping 可以正常工作,因此 DNS 解析器应该没有问题。
现在我能够找到更多的解决方案,例如强制 apt 使用 IPv4、删除虚拟机管理程序交换适配器和其他类似的解决方案,但它们的问题似乎与我所面临的问题无关,而且我不想继续在黑暗中射箭。
任何帮助或指引都将不胜感激。谢谢
错误日志:
$ sudo apt-get update
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
Err:5 http://archive.canonical.com/ubuntu focal InRelease
Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::16). - connect (101: Network is unreachable) Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::1b). - connect (101: Network is unreachable) Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1562::1c). - connect (101: Network is unreachable) Could not connect to archive.canonical.com:80 (91.189.92.191), connection timed out Could not connect to archive.canonical.com:80 (91.189.92.150), connection timed out Could not connect to archive.canonical.com:80 (91.189.91.15), connection timed out
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable)
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/focal/InRelease Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::16). - connect (101: Network is unreachable) Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1360:8c01::1b). - connect (101: Network is unreachable) Cannot initiate the connection to archive.canonical.com:80 (2001:67c:1562::1c). - connect (101: Network is unreachable) Could not connect to archive.canonical.com:80 (91.189.92.191), connection timed out Could not connect to archive.canonical.com:80 (91.189.92.150), connection timed out Could not connect to archive.canonical.com:80 (91.189.91.15), connection timed out
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
强制使用 IPv4 的错误日志:
sudo apt-get update -o Acquire::ForceIPv4=true
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Unable to connect to archive.ubuntu.com:http:
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Unable to connect to archive.ubuntu.com:http:
Err:5 http://archive.canonical.com/ubuntu focal InRelease
Could not connect to archive.canonical.com:80 (91.189.92.191), connection timed out Could not connect to archive.canonical.com:80 (91.189.92.150), connection timed out Could not connect to archive.canonical.com:80 (91.189.91.15), connection timed out
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/focal/InRelease Could not connect to archive.canonical.com:80 (91.189.92.191), connection timed out Could not connect to archive.canonical.com:80 (91.189.92.150), connection timed out Could not connect to archive.canonical.com:80 (91.189.91.15), connection timed out
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.