为什么 apt-get 无法解析镜像?

为什么 apt-get 无法解析镜像?

可能重复:
apt-get update 无法获取文件,“暂时无法解决...”错误

我知道之前已经讨论过这个问题,但我似乎无法解决我的问题。这是我的输出。

jake@KUBIE-SERVER:~$ sudo apt-get update
Err http://us.archive.ubuntu.com precise InRelease

Err http://us.archive.ubuntu.com precise-updates InRelease

Err http://us.archive.ubuntu.com precise-backports InRelease

Err http://security.ubuntu.com precise-security InRelease

Err http://archive.canonical.com precise InRelease

Err http://ppa.launchpad.net precise InRelease

Err http://archive.canonical.com precise Release.gpg
  Temporary failure resolving 'archive.canonical.com'
Err http://ppa.launchpad.net precise Release.gpg
  Temporary failure resolving 'ppa.launchpad.net'
Err http://security.ubuntu.com precise-security Release.gpg
  Temporary failure resolving 'security.ubuntu.com'
Err http://us.archive.ubuntu.com precise Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-updates Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Err http://us.archive.ubuntu.com precise-backports Release.gpg
  Temporary failure resolving 'us.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-        updates/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-  backports/InRelease

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease

W: Failed to fetch http://archive.canonical.com/ubuntu/dists/precise/InRelease

W: Failed to fetch     http://ppa.launchpad.net/webupd8team/java/ubuntu/dists/precise/InRelease

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg    Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise- updates/Release.gpg  Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-  backports/Release.gpg  Temporary failure resolving 'us.archive.ubuntu.com'

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-  security/Release.gpg  Temporary failure resolving 'security.ubuntu.com'

W: Failed to fetch http://archive.canonical.com/ubuntu/dists/precise/Release.gpg    Temporary failure resolving 'archive.canonical.com'

W: Failed to fetch   http://ppa.launchpad.net/webupd8team/java/ubuntu/dists/precise/Release.gpg  Temporary  failure resolving 'ppa.launchpad.net'

W: Some index files failed to download. They have been ignored, or old ones used  instead.

任何帮助是极大的赞赏。

答案1

我也遇到了同样的错误。我原本以为是中的错误/etc/apt/sources.list,但在执行了ping不仅如此security.ubuntu.com而且google.com也之后,我发现我的服务器正在连接到网络,但无法到达网络外部。

我编辑/etc/network/interfaces并设置eth0DHCP而不是静态。然后我让路由器负责为服务器提供静态 IP。重新启动服务器,一切正常。

您可以了解有关 IP 配置的更多信息这里

答案2

您还没有指定更多有关周围情况的详细信息来解释问题背后的原因。

Precise话虽如此,您似乎遇到了一些包管理问题,这可能是由于您使用的镜像所致,它可能缺少您所请求的包或者需要更新。

尝试这个:

  1. 打开终端并输入:

    sudo nano /etc/apt/sources.list
    

    编辑您的源文件。

  2. 在最开始的地方添加以下几行:

    deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse
    deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse
    deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse
    deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse
    

    这应该会apt-get根据您的地理位置自动为您选择一个镜像。

  3. 保存文件并更新您的源:

    sudo apt-get update
    

这假设您没有遇到任何互联网连接或 DNS 问题。

希望这可以帮助。

相关内容