Apt-get 更新在 Ubuntu 16.04 中不起作用“暂时失败解决”

Apt-get 更新在 Ubuntu 16.04 中不起作用“暂时失败解决”

首先,我对 Linux 命令行还不熟悉。我以前从未使用过它。我的问题是该命令apt-get update只会返回:

Err:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Err:2 http://us.archive.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'us.archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

我的sources.list文件如下所示:

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#


###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse 

###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse 
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse 
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse

我的ubuntu版本是:

Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-66-generic x86_64)

答案1

我遇到了同样的问题。问题的核心是无法解析 DNS。我丢失了我的/etc/resolv.conf文件。

其内容应为:

nameserver 8.8.8.8
nameserver 8.8.4.4

之后,重新启动正确的界面(我的是lo而不是eth0)。您可以在文件中找到它/etc/network/interfaces

答案2

我遇到了同样的问题,由错误的 DNS 设置引起:

sudo nano /etc/network/interfaces

在此文件中设置正确的 DNS 服务器:dns-nameservers 8.8.8.8

sudo ifdown eth0 && sudo ifup eth0

答案3

我遇到了同样的问题,但错误消息略有不同。这对我有用:

sudo nano /etc/network/interfaces

找到 的行dns-nameserver。如果没有,请按如下方式添加:

dns-nameserver 208.067.222.222

这是 OpenDNS 的地址。您也可以使用 8.8.8.8,这是 Google Public DNS 的地址。

相关内容