0%[连接到in.archive.ubuntu.com需要很长时间

时间:2018-06-14 11:06:39

标签: ubuntu networking

每当我运行必须连接到archive.ubuntu.com的命令时,该命令需要很长时间才能完成任务。

sudo apt install oracle-java8-installer -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gsfonts-x11 java-common oracle-java8-set-default
Suggested packages:
  binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho
  | ttf-sazanami-mincho ttf-arphic-uming
The following NEW packages will be installed:
  gsfonts-x11 java-common oracle-java8-installer oracle-java8-set-default
0 upgraded, 4 newly installed, 0 to remove and 29 not upgraded.
Need to get 54.7 kB of archives.
After this operation, 272 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/webupd8team/java/ubuntu artful/main amd64 oracle-java8-installer all 8u171-1~webupd8~0 [33.3 kB]
Get:2 http://ppa.launchpad.net/webupd8team/java/ubuntu artful/main amd64 oracle-java8-set-default all 8u171-1~webupd8~0 [6,846 B]
0% [Connecting to in.archive.ubuntu.com (2001:67c:1360:8001::21)]

ping 8.8.8.8:

ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=62.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=51.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=67.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=58.4 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=56 time=71.9 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=56 time=71.0 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=56 time=60.5 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=56 time=49.0 ms
^C
--- 8.8.8.8 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7005ms
rtt min/avg/max/mdev = 49.028/61.584/71.951/7.865 ms

我们可以看到上面的速度并不慢。

and ipv4 is :

请帮我避免这个问题。每次我遇到困难,都要等到任务完成。

3 个答案:

答案 0 :(得分:1)

您的问题可能在于程序包管理器尝试通过ipv6连接到存储库这一事实。

从您提供的日志中查看此行:

0% [Connecting to in.archive.ubuntu.com (2001:67c:1360:8001::21)]

之前我遇到过同样的问题,我通过强迫pm使用ipv4来解决它。

运行-o Acquire::ForceIPv4=true时添加apt-get

如果您想要将此设置设置为premanent,则应创建/etc/apt/apt.conf.d/99force-ipv4并将Acquire::ForceIPv4 "true";放入其中:

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

See also

答案 1 :(得分:0)

您可以强制使用IPV4,如下所示。

apt-get -o Acquire::ForceIPv4=true update
apt-get -o Acquire::ForceIPv4=true upgrade

答案 2 :(得分:0)

This solution至少对于Ubuntu 16仍然正确。要避免使用IPv6(这很可能会引起问题)并强制使用IPv4,只需打开文件即可:

sudo nano /etc/gai.conf

和取消注释行

precedence ::ffff:0:0/96  100