`apt-get update` 找不到 Ubuntu 服务器

Phr*_*ogz 57 apt

sudo apt-get update在我的服务器(有互联网连接)上运行失败。服务器是否暂时损坏,或者我的 APT 配置错误并使用旧服务器?简而言之,我该如何解决这个问题?

这是输出:

~$ uname -a
Linux nematode 2.6.28-19-server #66-Ubuntu SMP Sat Oct 16 18:41:24 UTC 2010 i686 GNU/Linux

~$ sudo apt-get update
Err http://us.archive.ubuntu.com jaunty Release.gpg
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/main Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/restricted Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/universe Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty/multiverse Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates Release.gpg
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/main Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/restricted Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/universe Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com jaunty-updates/multiverse Translation-en_US
  Could not resolve 'us.archive.ubuntu.com'
Err http://security.ubuntu.com jaunty-security Release.gpg
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/main Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/restricted Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/universe Translation-en_US
  Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com jaunty-security/multiverse Translation-en_US
  Could not resolve 'security.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/Release.gpg  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/main/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/restricted/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/universe/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/Release.gpg  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/main/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/restricted/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/universe/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/jaunty-updates/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'us.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/Release.gpg  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/main/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/restricted/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/universe/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jaunty-security/multiverse/i18n/Translation-en_US.bz2  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download, they have been ignored, or old ones used instead.
W: You may want to run apt-get update to correct these problems
Run Code Online (Sandbox Code Playgroud)

bra*_*rks 55

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

/etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)

有很好的 DNS 服务器条目。

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

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

nameserver 8.8.8.8 
nameserver 8.8.4.4
Run Code Online (Sandbox Code Playgroud)

当然,您需要以 root 身份更改此文件,并在进行任何更改之前进行备份!

  • 在那个文件中它说“不要手动编辑这个文件——你的更改将被覆盖”——你能解决这个问题吗? (3认同)
  • 如果您需要在自己的网络内解析地址,则不一定是一个好的计划。如果每台机器需要按名称访问的所有内容都位于防火墙之外,那很好。 (2认同)

gee*_*aur 23

你能从命令行解析任何这些主机吗?

jinx:775 Z$ ping us.archive.ubuntu.com
PING us.archive.ubuntu.com (91.189.92.171) 56(84) bytes of data.
64 bytes from cassava.canonical.com (91.189.92.171): icmp_seq=1 ttl=128 time=104 ms
Run Code Online (Sandbox Code Playgroud)

如果没有,下一步是尝试host -v

jinx:776 Z$ host -v us.archive.ubuntu.com
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14243
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      A

;; ANSWER SECTION:
us.archive.ubuntu.com.  592     IN      A       91.189.88.31
us.archive.ubuntu.com.  592     IN      A       91.189.88.40
us.archive.ubuntu.com.  592     IN      A       91.189.88.45
us.archive.ubuntu.com.  592     IN      A       91.189.88.46
us.archive.ubuntu.com.  592     IN      A       91.189.92.169
us.archive.ubuntu.com.  592     IN      A       91.189.92.170
us.archive.ubuntu.com.  592     IN      A       91.189.92.171
us.archive.ubuntu.com.  592     IN      A       91.189.88.30

Received 167 bytes from 10.211.55.1#53 in 37 ms
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50130
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      AAAA

;; AUTHORITY SECTION:
ubuntu.com.             1800    IN      SOA     ns1.canonical.com. hostmaster.canonical.com. 2011030301 10800 3600 604800 3600

Received 100 bytes from 10.211.55.1#53 in 65 ms
Trying "us.archive.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54875
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;us.archive.ubuntu.com.         IN      MX

;; AUTHORITY SECTION:
ubuntu.com.             1800    IN      SOA     ns1.canonical.com. hostmaster.canonical.com. 2011030301 10800 3600 604800 3600

Received 100 bytes from 10.211.55.1#53 in 62 ms
Run Code Online (Sandbox Code Playgroud)

查找 DNS 服务器返回的错误。

  • 我应该提到`ping`也没有解决,但我能够通过IP ping(在单独的机器上解决)。多亏了这个帮助和@ændrük 的评论,我发现我的 DNS 条目以某种方式完全没用。修复那些修复了问题。 (2认同)

小智 17

我知道这个线程是超级旧的,但对于任何仍在查看的人,我通过断开并重新连接到无线接入点来解决这个问题。


小智 10

我经常在 /etc/resolv.conf 中使用 8.8.8.8 来解决这个问题。特别是在处理不稳定的当月廉价云提供商(在本例中为 linode)的东西时。

猫 /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
#nameserver 72.14.179.5
#nameserver 72.14.188.5
Run Code Online (Sandbox Code Playgroud)

这些是 Google 的公共 DNS 服务器。是的,他们可能会跟踪那些日志。但我倾向于在这些服务器上访问的唯一站点是 git 和 ubuntu 档案。