我有Ubuntu 13.04 服务器在 Virtual Box 上,它使用了 2GB 的 RAM 和 20GB 的空间。它是新安装的,我无法使用 apt-get update。
我也尝试过同样的方法Ubuntu 12.10 服务器但它仍然不起作用。
每次我输入 apt-get update 时都会得到
0% [Connecting to ca.archive.ubuntu.com (91.189.92.202)] [Connecting to security.ubuntu.com (91.189.91.15)]
然后挂起大约 20 分钟,然后显示
Err http://security.ubuntu.com raring-security Release.gpg
Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
Err http://ca.archive.ubuntu.com raring Release.gpg
Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
Err http://ca.archive.ubuntu.com raring-updates Release.gpg
Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
Err http://ca.archive.ubuntu.com raring-backports Release.gpg
Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
Reading package lists... Done
W: Failed to fetch http://ca.archive.ubuntu.com/ubuntu/dists/raring/Release.gpg Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
W: Failed to fetch http://ca.archive.ubuntu.com/ubuntu/dists/raring-updates/Release.gpg Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
W: Failed to fetch http://ca.archive.ubuntu.com/ubuntu/dists/raring-backports/Release.gpg Cannot initiate the connection to ca.archive.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/raring-security/Release.gpg Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8c01::1a). - connect (101: Network is unreachable) [IP: 2001:67c:1360:8c01::1a 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.
但是我可以 ping 服务器上的 IP 地址和域,并且可以在主机浏览器上访问它
davidrockin@ubuntu:/etc/apt$ ping -c 2 ca.archive.ubuntu.com
PING ca.archive.ubuntu.com (91.189.91.13) 56(84) bytes of data.
64 bytes from ragana.canonical.com (91.189.91.13): icmp_req=1 ttl=49 time=42.0 ms
64 bytes from ragana.canonical.com (91.189.91.13): icmp_req=2 ttl=49 time=43.3 ms
--- ca.archive.ubuntu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 42.088/42.742/43.396/0.654 ms
davidrockin@ubuntu:/etc/apt$ ping -c 2 91.189.92.202
PING 91.189.92.202 (91.189.92.202) 56(84) bytes of data.
64 bytes from 91.189.92.202: icmp_req=1 ttl=49 time=101 ms
p64 bytes from 91.189.92.202: icmp_req=2 ttl=49 time=98.9 ms
--- 91.189.92.202 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 98.976/100.335/101.695/1.395 ms
davidrockin@ubuntu:/etc/apt$ ping -c 3 security.ubuntu.com
PING security.ubuntu.com (91.189.91.14) 56(84) bytes of data.
64 bytes from orobas.canonical.com (91.189.91.14): icmp_req=1 ttl=52 time=112 ms
64 bytes from orobas.canonical.com (91.189.91.14): icmp_req=2 ttl=52 time=44.5 ms
^C64 bytes from orobas.canonical.com (91.189.91.14): icmp_req=3 ttl=52 time=41.0 ms
--- security.ubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 41.038/66.103/112.679/32.967 ms
我尝试过修改我的/etc/apt/sources.list文件使用不同的存储库
这是我现在的/etc/apt/sources.list文件,这是 Ubuntu 安装时创建的原始文件。
deb http://ca.archive.ubuntu.com/ubuntu/ raring main restricted
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://ca.archive.ubuntu.com/ubuntu/ raring-updates main restricted
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring-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://ca.archive.ubuntu.com/ubuntu/ raring universe
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring universe
deb http://ca.archive.ubuntu.com/ubuntu/ raring-updates universe
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring-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://ca.archive.ubuntu.com/ubuntu/ raring multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ raring-updates multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring-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://ca.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://ca.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu raring-security main restricted
deb-src http://security.ubuntu.com/ubuntu raring-security main restricted
deb http://security.ubuntu.com/ubuntu raring-security universe
deb-src http://security.ubuntu.com/ubuntu raring-security universe
deb http://security.ubuntu.com/ubuntu raring-security multiverse
deb-src http://security.ubuntu.com/ubuntu raring-security multiverse
我尝试过重新启动计算机、重新安装虚拟机、多次重新启动路由器、修改 sources.list,并且已经在 Google 上搜索了几个小时,但仍无法弄清楚为什么它不起作用。
我还尝试禁用 IPv6(http://www.bearfruit.org/2013/05/06/ubuntu-server-having-ipv6-probs-its-easy-to-disable/)
昨晚我设置了一个 Ubuntu 服务器来测试它,昨晚 apt-get update 工作正常。现在,它在新的虚拟机上不再工作了。我昨天创建的虚拟机已被删除,而我今天创建的新虚拟机不起作用。
我的主机是一台笔记本电脑,我正在使用 wifi,它的规格是
Windows 7
8GB Ram
658 GB HDD (214 GB used)
AMD A8-3520M APU
编辑:我没有使用代理/vpn,并且我的互联网连接良好。
答案1
我意识到我很愚蠢,这与存储库或虚拟机配置无关。
我所要做的就是禁用 avast 上的防火墙。我完全忘记了这件事。
答案2
看起来它使用 ipv6 进行 apt-get 和 ipv4 进行 ping。也许值得尝试使用内核参数禁用 ipv6,尽管我自己很长时间不需要这样做了。在 /etc/default/grub中ipv6.disable=1
添加GRUB_CMDLINE_LINUX_DEFAULT=...
sudo update-grub
答案3
为了将来参考,我遇到了这个问题,因为我们有一个公司代理,并且我使用了 sudo:
sudo apt-get update
但http_proxy
环境变量被遗忘了...切换到:
sudo -E apt-get update
让一切恢复正常运转。
答案4
如果您尝试从代理服务器连接,请确保在
vi /etc/apt/apt.conf
Acquire::http::Proxy "http_colon//proxyserverip:proxyport";
然后尝试
apt-get update
这应该可以帮助你解决这个问题。