无法在 WSL2 上使用 apt,但 ping 可以

无法在 WSL2 上使用 apt,但 ping 可以

我正在尝试使用 Ubuntu 的 WSL2 安装。

apt-get不起作用。例如,如果我想安装,net-tools我会得到

daniele@IOS-PC:~$ sudo apt-get install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1
  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
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb  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
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

奇怪的是,我能够 ping 通服务器的 IP 地址和名称:

daniele@IOS-PC:~$ ping 91.189.88.152
PING 91.189.88.152 (91.189.88.152) 56(84) bytes of data.
64 bytes from 91.189.88.152: icmp_seq=1 ttl=52 time=50.0 ms
64 bytes from 91.189.88.152: icmp_seq=2 ttl=52 time=50.5 ms
64 bytes from 91.189.88.152: icmp_seq=3 ttl=52 time=51.1 ms
64 bytes from 91.189.88.152: icmp_seq=4 ttl=52 time=50.7 ms
^C
--- 91.189.88.152 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 50.006/50.578/51.086/0.386 ms
daniele@IOS-PC:~$ ping archive.ubuntu.com
PING archive.ubuntu.com (91.189.88.142) 56(84) bytes of data.
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=1 ttl=52 time=53.4 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=2 ttl=52 time=51.0 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=3 ttl=52 time=50.8 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=4 ttl=52 time=51.4 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=5 ttl=52 time=50.0 ms
64 bytes from aerodent.canonical.com (91.189.88.142): icmp_seq=6 ttl=52 time=50.2 ms
^C
--- archive.ubuntu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 49.958/51.127/53.421/1.135 ms

如何apt-get正确使用该命令?

答案1

最近,我遇到了类似的问题,我无法使用新的 Docker Desktop(基于 WSL 2)提取 Docker 映像。其他人也遇到过这种情况,并发现了以下问题:AVM FritzBox 路由器的硬件加速防火墙存在一个错误。

唯一的“解决方案”(实际上是变通方法)是关闭防火墙加速器。为此,请转到http://fritz.box/support.lua(或http://192.168.178.1/support.lua或其他)并登录。在此页面上的某个地方,您会找到一个用于控制防火墙硬件加速的复选框。在德语中,它看起来像这样:

数据包加速选项

只需禁用它并再试一次。

但请注意:这将严重限制 FritzBox 的路由性能。如果您订阅了快速互联网,您会感觉到这一点。

相关内容