我不能使用apt-get update

我在虚拟盒上有Ubuntu 13.04服务器 ,它使用2GB内存和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 Installed时创建的原始文件。

 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 ## NB 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 ## NB 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 ## NB 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,我一直在谷歌上搜索几个小时,并且无法弄清楚它为什么不起作用。

我也试图禁用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后面,我的网络连接很好。

意识到我很愚蠢,它与存储库或虚拟机配置无关。

我所要做的就是在avast上禁用防火墙。 我完全忘了的东西。

看起来它正在使用ipv6来apt-get和ipv4来ping。 尝试使用内核参数禁用ipv6可能是值得尝试的,虽然我自己很长时间都不需要这样做。 在/ etc / default / grub中将ipv6.disable=1添加到GRUB_CMDLINE_LINUX_DEFAULT=...然后sudo update-grub

为了将来参考,我遇到了这个问题,因为我们有一个公司代理,我使用的是sudo:

 sudo apt-get update 

http_proxy env var留下了……切换到:

 sudo -E apt-get update 

一切都在滚动。

案例1:终端中的问题尝试使用主根终端,Linux有两个终端,尝试使用根终端

 $ sudo passwd root [sudo] password for ramesh: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully 

这个用于root设置,

案例2:正确安装sudo包,如果sudo命令不起作用

在终端输入

 tar -xzf archive.tar.gz 

或这个

 tar -xzf archive-name.tar.gz cd archive-name ./configure make sudo make install 

情况3:如果上述命令不起作用,请尝试使用这些命令

检查终端中的错误

 auto-apt run  

要么

 apt-get check 

要么

 dpkg-reconfigure fontconfig-config 

如果您尝试从代理服务器后面进行连接,请确保完成正确的代理设置

 vi /etc/apt/apt.conf Acquire::http::Proxy "http_colon//proxyserverip:proxyport"; 

然后试试

 apt-get update 

这应该会让你了解这个问题。