我正在家用服务器上试用 Ubuntu Server 12.04,但更新不起作用。不知道原因。
我已执行 sudo su 和 apt-get update。之后我得到以下内容:
Err gb.archive.ubuntu.com precise InRelease
Err gb.archive.ubuntu.com precise-updates InRelease
Err gb.archive.ubuntu.com precise-backports InRelease
Err security.ubuntu.com precise-security InRelease
Err archive.canonical.com precise InRelease
Err extras.ubuntu.com precise InRelease
Err gb.archive.ubuntu.com precise Release.gpg
Temporary failure resolving âgb.archive.ubuntu.comâ
Err gb.archive.ubuntu.com precise-updates Release.gpg
Temporary failure resolving âgb.archive.ubuntu.comâ
Err security.ubuntu.com precise-security Release.gpg
Temporary failure resolving âsecurity.ubuntu.comâ
Err archive.canonical.com precise Release.gpg
Temporary failure resolving âarchive.canonical.comâ
Err gb.archive.ubuntu.com precise-backports Release.gpg
Temporary failure resolving âgb.archive.ubuntu.comâ
Err extras.ubuntu.com precise Release.gpg
Temporary failure resolving âextras.ubuntu.comâ
Reading package lists... Done
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise/InRelease
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease
W: Failed to fetch security.ubuntu.com/ubuntu/dists/precise-security/InRelease
W: Failed to fetch archive.canonical.com/ubuntu/dists/precise/InRelease
W: Failed to fetch extras.ubuntu.com/ubuntu/dists/precise/InRelease
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving âgb.archive.ubuntu.comâ
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving âgb.archive.ubuntu.comâ
W: Failed to fetch gb.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving âgb.archive.ubuntu.comâ
W: Failed to fetch security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving âsecurity.ubuntu.comâ
W: Failed to fetch archive.canonical.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving âarchive.canonical.comâ
W: Failed to fetch extras.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving âextras.ubuntu.comâ
W: Some index files failed to download. They have been ignored, or old ones used instead.
有一些奇怪的字符没有出现在 /etc/apt/sources.list 中
大家有什么想法吗?NB:我必须删除 http://,否则我就无法发帖。
短暂性脑缺血发作
戴夫
答案1
我认为奇怪的字符是由于您的区域设置造成的,但我不认为这是您的问题。
暂时无法解析“gb.archive.ubuntu.com”
然而,这表明您的机器正在使用配置的 DNS 解析器,/etc/resolv.conf
无法解析gb.archive.ubuntu.com
遇到此错误时,请检查命令是否host gb.archive.ubuntu.com
返回如下 IP 地址列表:
gb.archive.ubuntu.com has address 194.169.254.10
gb.archive.ubuntu.com has address 91.189.92.156
gb.archive.ubuntu.com has address 91.189.92.177
gb.archive.ubuntu.com has address 91.189.92.200
gb.archive.ubuntu.com has address 91.189.92.201
gb.archive.ubuntu.com has address 91.189.92.202
gb.archive.ubuntu.com has IPv6 address 2a01:450:10:1::10
如果没有,请查看前面提到的文件中的解析器配置 - 它应该至少包含一行,其中nameserver x.x.x.x
xxxx 是解析器的 IP 地址。
如果存在,您可以暂时使用已知有效的公共解析器:
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
然后看看它是否有效。如果这没有帮助,你可能有一个更严重的网络问题,但这应该可以帮助你入门。
答案2
我的问题出在 的接口文件中/etc/network/interfaces
。在 Ubuntu 12.04 中,你必须有一个 dns-nameservers 行,例如
dns-nameservers 8.8.8.8 8.8.4.4
编辑此文件并将 8.8.8.8 8.8.4.4 替换为您的名称服务器 IP,每个 IP 之间用空格分隔。如果没有此行,请添加它。然后重新启动您的网络:
/etc/init.d/networking restart
在这种情况下,这解决了 DNS 问题。