即使强制使用 IPv4、清除 DNS 缓存、更改镜像后,apt update 仍无法连接到 archive.ubuntu.com

即使强制使用 IPv4、清除 DNS 缓存、更改镜像后,apt update 仍无法连接到 archive.ubuntu.com

出现此错误sudo apt update

Err:8 http://in.archive.ubuntu.com/ubuntu bionic InRelease                             
  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable) Could not connect to in.archive.ubuntu.com:80 (103.97.84.254), connection timed out


经过搜索,我发现解析 IPv6 地址可能存在问题。因此,强制使用 IPv4 sudo apt -o Acquire::ForceIPv4=true update,尽管如上所示,apt 尝试使用 IPv4。

Err:8 http://in.archive.ubuntu.com/ubuntu bionic InRelease                                             
  Could not connect to in.archive.ubuntu.com:80 (103.97.84.254), connection timed out


为了确保问题不是由其他 ppa 引起的,我重置了我/etc/apt/sources.listhttp://repogen.simplylinux.ch/。还是没解决问题。

Hit:1 http://ppa.launchpad.net/audio-recorder/ppa/ubuntu bionic InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable InRelease                                           
Hit:3 http://packages.microsoft.com/repos/vscode stable InRelease                                      
Hit:4 http://ppa.launchpad.net/bookworm-team/bookworm/ubuntu bionic InRelease                          
Hit:5 http://repo.steampowered.com/steam precise InRelease                                             
Hit:6 http://ppa.launchpad.net/kritalime/ppa/ubuntu bionic InRelease                                   
Hit:7 http://ppa.launchpad.net/rvm/smplayer/ubuntu bionic InRelease                                    
Err:8 http://in.archive.ubuntu.com/ubuntu bionic InRelease                             
  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable) Could not connect to in.archive.ubuntu.com:80 (103.97.84.254), connection timed out
Err:9 http://in.archive.ubuntu.com/ubuntu bionic-security InRelease
  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable)
Err:10 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
182 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable) Could not connect to in.archive.ubuntu.com:80 (103.97.84.254), connection timed out
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable)
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

还尝试更换镜像。错误仍然存​​在

最后我尝试使用查看调试信息sudo apt -oDebug::pkgAcquire::Worker=1 update,但输出没有提供额外的信息

Hit:7 http://ppa.launchpad.net/rvm/smplayer/ubuntu bionic InRelease               
0% [Connecting to in.archive.ubuntu.com (2403:8940:ffff::f)] <- gpgv:200%20URI%20Start%0aURI:%20gpgv:/var/lib/apt/lists/ppa.launchpad.net_rvm_smplayer_ubuntu_dists_bionic_InRelease
0% [7 InRelease gpgv 15.4 kB] [Connecting to in.archive.ubuntu.com (2403:8940:ffff::f)] <- gpgv:201%20URI%20Done%0aGPGVOutput:%20GOODSIG%20A7E13D78E4A4F4F4%0aURI:%20gpgv:/var/lib/apt/lists/ppa.launchpad.net_rvm_smplayer_ubuntu_dists_bionic_InRelease%0aFilename:%20/var/lib/apt/lists/ppa.launchpad.net_rvm_smplayer_ubuntu_dists_bionic_InRelease
0% [Connecting to in.archive.ubuntu.com (2403:8940:ffff::f)] <- http:400%20URI%20Failure%0aTransient-Failure:%20true%0aFailReason:%20Timeout%0aURI:%20http://in.archive.ubuntu.com/ubuntu/dists/bionic/InRelease%0aMessage:%20Cannot%20initiate%20the%20connection%20to%20in.archive.ubuntu.com:80%20(2403:8940:ffff::f).%20-%20connect%20(101:%20Network%20is%20unreachable)%20Could%20not%20connect%20to%20in.archive.ubuntu.com:80%20(103.97.84.254),%20connection%20timed%20out
Err:8 http://in.archive.ubuntu.com/ubuntu bionic InRelease  
  Cannot initiate the connection to in.archive.ubuntu.com:80 (2403:8940:ffff::f). - connect (101: Network is unreachable) Could not connect to in.archive.ubuntu.com:80 (103.97.84.254), connection timed out
0% [Working] <- http:102%20Status%0aURI:%20http://in.archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease%0aMessage:%20Connecting%20to%20in.archive.ubuntu.com%20(103.97.84.254)
 <- http:102%20Status%0aURI:%20http://in.archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease%0aMessage:%20Connecting%20to%20in.archive.ubuntu.com%20(2403:8940:ffff::f)
 <- http:400%20URI%20Failure%0aFailReason:%20Timeout%0aURI:%20http://in.archive.ubuntu.com/ubuntu/dists/bionic-security/InRelease%0aMessage:%20Cannot%20initiate%20the%20connection%20to%20in.archive.ubuntu.com:80%20(2403:8940:ffff::f).%20-%20connect%20(101:%20Network%20is%20unreachable)

我也尝试使用删除 DNS 缓存sudo systemd-resolve --flush-caches

额外信息 /etc/apt/sources.list

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#

##### Mirror
#deb http://mirror.cse.iitk.ac.in/ubuntu/ bionic main 
#deb-src http://mirror.cse.iitk.ac.in/ubuntu/ bionic main 

###### Ubuntu Main Repos
deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse

###### Ubuntu Update Repos
deb http://in.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://in.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

ping in.archive.ubuntu.com

$ ping in.archive.ubuntu.com
PING ubuntu-archive.mirrors.estointernet.in (103.97.84.254) 56(84) bytes of data.
64 bytes from 103.97.84.254 (103.97.84.254): icmp_seq=1 ttl=57 time=100 ms
64 bytes from 103.97.84.254 (103.97.84.254): icmp_seq=2 ttl=57 time=99.7 ms
64 bytes from 103.97.84.254 (103.97.84.254): icmp_seq=3 ttl=57 time=100 ms
64 bytes from 103.97.84.254 (103.97.84.254): icmp_seq=4 ttl=57 time=100 ms

评论

我裁剪了调试输出以删除不必要的输出,但我可以编辑以发布完整的输出。

在其他问题中我发现问题主要出在 DNS 上,但我能够 ping 服务器,所以这应该不是问题。

问题

有没有什么办法可以解决这个问题?如果没有,有没有办法重置 DNS+apt+sources 以便一切正常(除了重新安装 ubuntu)?

编辑:此外,当我重置 sources.list 时,我仍然看到额外的 ppa,如 steam ppa、kritalime ppa 等...我在写入 sources.list 后是否遗漏了什么?

答案1

由于连接.archive.ubuntu.com 本身存在问题,我通过将所有 URL 更改为工作镜像来解决这个问题。

/etc/apt/sources.list

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#

##### Mirror
deb http://mirror.cse.iitk.ac.in/ubuntu/ bionic main 
deb-src http://mirror.cse.iitk.ac.in/ubuntu/ bionic main 

###### Ubuntu Main Repos
#deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
#deb-src http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse

###### Ubuntu Update Repos
deb http://mirror.cse.iitk.ac.in/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirror.cse.iitk.ac.in/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirror.cse.iitk.ac.in/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirror.cse.iitk.ac.in/ubuntu/ bionic-updates main restricted universe multiverse

相关内容