apt-get 通常会失败,软件包和更新

apt-get 通常会失败,软件包和更新

我正在使用虚拟盒运行 Ubuntu 服务器 14.04.4 的虚拟机。我已将网络配置为“桥接适配器”配置。我已手动分配与主机 Windows 计算机所在网络相同地址的 IP。网关是无线路由器。我能够 ping 通公共 IP,并且 URI 也正在转换。

当我尝试使用 安装“chrony”之类的软件包时,sudo apt-get install chrony我立即得到以下输出。

root@controller:~# apt-get install chrony
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package chrony

当我尝试使用更新 apt 时,sudo apt-get update我得到了输出,

    root@controller:~# apt-get update
Err http://extras.ubuntu.com trusty InRelease

Err http://extras.ubuntu.com trusty Release.gpg
  Unable to connect to extras.ubuntu.com:http:
Err http://archive.canonical.com trusty InRelease

Err http://archive.canonical.com trusty Release.gpg
  Unable to connect to archive.canonical.com:http: [IP: 91.189.92.150 80]
Err http://in.archive.ubuntu.com trusty InRelease

Err http://in.archive.ubuntu.com trusty-updates InRelease

Err http://in.archive.ubuntu.com trusty-backports InRelease

Err http://in.archive.ubuntu.com trusty Release.gpg
  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]
Err http://in.archive.ubuntu.com trusty-updates Release.gpg
  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]
Err http://in.archive.ubuntu.com trusty-backports Release.gpg
  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]
Err http://security.ubuntu.com trusty-security InRelease

Err http://security.ubuntu.com trusty-security Release.gpg
  Unable to connect to security.ubuntu.com:http: [IP: 91.189.91.23 80]
Reading package lists... Done
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease

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

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

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/trusty/InRelease

W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Unable to connect to extras.ubuntu.com:http:

W: Failed to fetch http://archive.canonical.com/ubuntu/dists/trusty/Release.gpg  Unable to connect to archive.canonical.com:http: [IP: 91.189.92.150 80]

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg  Unable to connect to in.archive.ubuntu.com:http: [IP: 91.189.88.152 80]

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Unable to connect to security.ubuntu.com:http: [IP: 91.189.91.23 80]

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

我的/etc/network/interfaces是:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1

#2nd if
auto eth1
iface eth1 inet static
address 192.168.1.100
netmask 255.255.255.0
#gateway 192.168.0.1


dns-nameservers 8.8.8.8 4.2.2.2

我的/etc/apt/sources.list文件看起来像这样

#deb cdrom:[Ubuntu-Server 14.04.4 LTS _Trusty Tahr_ - Release amd64 (20160217.1)]/ trusty main restricted

#deb cdrom:[Ubuntu-Server 14.04.4 LTS _Trusty Tahr_ - Release amd64 (20160217.1)]/ trusty main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://in.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty universe
deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

我曾尝试禁用 IPv6 路由。我以前尝试时没有遇到过这样的问题,三天后我感到很困惑。任何见解都将不胜感激。感觉我错过了一些显而易见的事情,但却没有意识到。

非常感谢。

答案1

尝试 ping ' google.com'...如果 ping 失败,则执行以下操作:

编辑/etc/resolv.conf和添加

注意:您可以使用任何文本编辑器,例如“ vi /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

位于末尾/etc/resolv.conf- 如果是空文件则位于顶部。

现在应该可以工作了,请在评论中告诉我发生了什么:)

编辑:我注意到在 /etc/network/interfaces 中 - 您已经将“dns-nameservers”字段初始化到 Google 名称服务器,但也请尝试按照我的方法执行此操作 :)

答案2

编辑:好吧!这个解决方案将 100% 修复它(我希望)...因为我尝试使用你的'sources.list' 复制,我遇到了同样的问题...之后,我尝试使用下面的方法恢复默认的 'sources.list',它100% 工作d(已测试!):)

好吧,既然您的网络设置没有问题,而且您能够 ping 通所有东西。让我们恢复sources.listUbuntu 安装的默认“ ”文件。

因此,首先删除损坏的“ sources.list”,然后我们将在接下来的步骤中替换它:

sudo rm /etc/apt/sources.list

现在打开' software-properties-gtk',它将自动创建一个新的空' sources.list'文件

sudo software-properties-gtk

在 ' software-properties-gtk' 中勾选(选中) ' Community-maintained free and open-source software (universe)'

然后将“ Download from:”设置为“ Server for USA”或任何靠近您所在位置的服务器。

当然,请单击“ Revert”按钮。

图像

相关内容