无法使用 sudo apt-get update

无法使用 sudo apt-get update

我在 Hyper-V 中创建了一个 Ubuntu Server 20.04 VM,每当我尝试运行 sudo apt-get update 时,我都会得到以下返回:

Get:1 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB]
Err:2 http://be.archive.ubuntu.com/ubuntu focal InRelease
  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to be.archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.91.38), connection timed out
Err:3 http://be.archive.ubuntu.com/ubuntu focal-updates InRelease
  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
Err:4 http://be.archive.ubuntu.com/ubuntu focal-backports InRelease
  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
Err:5 http://be.archive.ubuntu.com/ubuntu focal-security InRelease
  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
Fetched 57.7 kB in 32s (1,828 B/s)
Reading package lists... Done
W: Failed to fetch http://be.archive.ubuntu.com/ubuntu/dists/focal/InRelease  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to be.archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to be.archive.ubuntu.com:80 (91.189.91.38), connection timed out
W: Failed to fetch http://be.archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
W: Failed to fetch http://be.archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
W: Failed to fetch http://be.archive.ubuntu.com/ubuntu/dists/focal-security/InRelease  Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to be.archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

我可以 ping 通,也可以下载 docker 镜像并在 docker 容器内使用 sudo apt-get update。所以我假设我确实有某种网络连接?
有人知道我做错了什么或我该如何解决这个问题吗?
谢谢!

编辑:
我也可以 ping 到 8.8.8.8 和 be.archive.ubuntu.com!

答案1

这可能是您的防火墙与网络代理冲突的原因。防火墙的配置方式(考虑出厂设置)是对网络流量施加更严格的协议。当与代理结合使用时,它会获取您的 Ipv6 并将其发送到服务器库,然后再发送到目标域。

当代理过载时,会导致流量大幅下降。8.8.8.8 是 Google 的标准停靠地址,速度很慢(至少在我使用它时)。您使用的代理可能是 DNS 超时的原因。我建议执行以下操作:

1.检查防火墙是否阻止了端口

        sudo telnet google.com 80

2.如果您收到错误,只需转到活动页面启动防火墙 GUI 并解除对端口 80 的阻止。我个人会通过 wifi 设置或以太网禁用代理

3.如果 apt-get update 仍然不起作用,则可能是由于软件存储库的问题。如果您关注收到的预发布版本,则可能必须删除这些预发布软件包。

 sudo apt-remove [name of repository]

然后,转到活动上的软件和更新,取消选中预发布。

我是在这个网站上回答和互动的新手,因此对于任何编辑错误,我深表歉意。

我希望这会有所帮助,祝你好运。

相关内容