在 Linux 18.04 中无法使用 sudo apt-get update

在 Linux 18.04 中无法使用 sudo apt-get update

这是我尝试运行 sudo apt-get update 或尝试安装任何东西时得到的输出。

sudo apt-get update 
Err:1 http://dl.google.com/linux/chrome/deb stable InRelease
  Could not resolve ‘dl.google.com’
Err:2 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
  Could not resolve ‘gb.archive.ubuntu.com’
Err:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease
  Could not resolve ‘gb.archive.ubuntu.com’
Err:4 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease
  Could not resolve ‘gb.archive.ubuntu.com’
Err:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Could not resolve ‘security.ubuntu.com’
Reading package lists... Done
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not resolve ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Could not resolve ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Could not resolve ‘gb.archive.ubuntu.com’
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not resolve ‘security.ubuntu.com’
W: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/InRelease  Could not resolve ‘dl.google.com’
W: Some index files failed to download. They have been ignored, or old ones used instead.

我也无法访问 github,告诉我 github 无法解析。

有任何线索可以解释这是什么原因造成的吗?

更新:来自 traceroute 的输出

traceroute dl.google.com
traceroute to dl.google.com (216.58.210.46), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * peer7-et-0-0-1.telehouse.ukcore.bt.net (62.172.103.158)  20.930 ms peer8-et-0-1-4.telehouse.ukcore.bt.net (109.159.252.106)  20.638 ms
 7  109.159.253.235 (109.159.253.235)  22.406 ms 195.99.126.75 (195.99.126.75)  25.586 ms 109.159.253.93 (109.159.253.93)  24.234 ms
 8  * * *
 9  72.14.236.224 (72.14.236.224)  27.654 ms 108.170.234.160 (108.170.234.160)  27.338 ms 74.125.252.128 (74.125.252.128)  28.687 ms
10  * * *
11  * * lhr25s11-in-f14.1e100.net (216.58.210.46)  20.101 ms

答案1

这听起来像是 DNS 问题。要修复它,您需要确保

/etc/resolv.conf 有 DNS 服务器的良好条目。

Google 有您可以使用的公共 DNS 服务器。

例如,您可以将以下两行添加到 /etc/resolv.conf 文件的顶部(这些指向 Google DNS 服务器),如上所述:

名称服务器 8.8.8.8 名称服务器 8.8.4.4

此外,如果您使用代理,请确保您已创建/修改文件 /etc/apt/apt.conf 以指定您的代理,如下所示:

获取::http::代理”http://你的代理:端口“;

获取::https::代理”http://你的代理:端口“;

获取::ftp::代理”http://你的代理:端口“;

相关内容