如何解决 apt-get update 错误“无法解决”?

如何解决 apt-get update 错误“无法解决”?

我刚刚从 VPS 提供商那里购买了服务器空间。我要做的第一件事就是安装最新版本的 Nginx。我按照 Nginx 的官方说明进行操作这里。一切都很顺利,直到我运行sudo apt-get update。出于某种原因,似乎/etc/apt/sources.list除了我手动添加的 Nginx 存储库之外,所有存储库都更新正确。

我的局域网上有一个测试服务器,我的设置与这个虚拟专用服务器完全相同,所以我知道配置有效。

我对这一切还比较陌生,我不知道是什么原因造成的,我在网上也找不到遇到同样问题的人,但是我根据找到的信息尝试了以下诊断步骤:

删除了所有名称服务器/etc/resolv.conf,只添加了谷歌的8.8.8.8- 并没有解决问题,然后当我运行时,所有的存储库都出现了错误sudo apt-get update

每当我尝试做ping任何事情时,结果总是connect: Network is unreachable

但如果我运行host www.google.com,例如,我会得到这个输出:

www.google.com has address 74.125.28.147
www.google.com has address 74.125.28.99
www.google.com has address 74.125.28.103
www.google.com has address 74.125.28.104
www.google.com has address 74.125.28.105
www.google.com has address 74.125.28.106
www.google.com has IPv6 address 2607:f8b0:400e:c04::93

这是输出sudo apt-get update

Err http://nginx.org trusty InRelease

Err http://nginx.org trusty Release.gpg                                 
  Could not resolve 'nginx.org'
Ign http://mirrors.gandi.net trusty InRelease                                  
Hit http://mirrors.gandi.net trusty Release.gpg                                
Hit http://mirrors.gandi.net trusty Release                                    
Ign http://us.archive.ubuntu.com trusty InRelease
Ign http://security.ubuntu.com trusty-security InRelease
Hit http://mirrors.gandi.net trusty/main amd64 Packages              
Ign http://us.archive.ubuntu.com trusty-updates InRelease                      
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]  
Ign http://us.archive.ubuntu.com trusty-backports InRelease           
Get:2 http://security.ubuntu.com trusty-security Release [63.5 kB]    
Hit http://us.archive.ubuntu.com trusty Release.gpg                            
Ign http://mirrors.gandi.net trusty/main Translation-en                        
Get:3 http://us.archive.ubuntu.com trusty-updates Release.gpg [933 B]          
Hit http://us.archive.ubuntu.com trusty-backports Release.gpg
Hit http://us.archive.ubuntu.com trusty Release          
Get:4 http://security.ubuntu.com trusty-security/main Sources [80.6 kB]
Get:5 http://us.archive.ubuntu.com trusty-updates Release [63.5 kB]
Hit http://us.archive.ubuntu.com trusty-backports Release             
Get:6 http://security.ubuntu.com trusty-security/restricted Sources [2061 B]
Hit http://us.archive.ubuntu.com trusty/main Sources
Get:7 http://security.ubuntu.com trusty-security/universe Sources [24.9 kB]
Hit http://us.archive.ubuntu.com trusty/restricted Sources                     
Get:8 http://security.ubuntu.com trusty-security/multiverse Sources [2335 B]
Hit http://us.archive.ubuntu.com trusty/universe Sources
Get:9 http://security.ubuntu.com trusty-security/main amd64 Packages [268 kB]
Hit http://us.archive.ubuntu.com trusty/multiverse Sources                 
Hit http://us.archive.ubuntu.com trusty/main amd64 Packages                
Hit http://us.archive.ubuntu.com trusty/restricted amd64 Packages          
Hit http://us.archive.ubuntu.com trusty/universe amd64 Packages            
Hit http://us.archive.ubuntu.com trusty/multiverse amd64 Packages           
Hit http://us.archive.ubuntu.com trusty/main Translation-en                 
Get:10 http://security.ubuntu.com trusty-security/restricted amd64 Packages [8875 B]
Hit http://us.archive.ubuntu.com trusty/multiverse Translation-en              
Get:11 http://security.ubuntu.com trusty-security/universe amd64 Packages [103 kB]
Hit http://us.archive.ubuntu.com trusty/restricted Translation-en             
Get:12 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [3680 B]
Hit http://us.archive.ubuntu.com trusty/universe Translation-en                
Hit http://security.ubuntu.com trusty-security/main Translation-en 
Get:13 http://us.archive.ubuntu.com trusty-updates/main Sources [202 kB]
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en     
Hit http://security.ubuntu.com trusty-security/restricted Translation-en       
Hit http://security.ubuntu.com trusty-security/universe Translation-en         
Get:14 http://us.archive.ubuntu.com trusty-updates/restricted Sources [2564 B]
Get:15 http://us.archive.ubuntu.com trusty-updates/universe Sources [117 kB]
Get:16 http://us.archive.ubuntu.com trusty-updates/multiverse Sources [5161 B]
Get:17 http://us.archive.ubuntu.com trusty-updates/main amd64 Packages [516 kB]
Get:18 http://us.archive.ubuntu.com trusty-updates/restricted amd64 Packages [9238 B]
Get:19 http://us.archive.ubuntu.com trusty-updates/universe amd64 Packages [279 kB]
Get:20 http://us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [12.0 kB]
Hit http://us.archive.ubuntu.com trusty-updates/main Translation-en            
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Translation-en      
Hit http://us.archive.ubuntu.com trusty-updates/restricted Translation-en      
Hit http://us.archive.ubuntu.com trusty-updates/universe Translation-en        
Hit http://us.archive.ubuntu.com trusty-backports/main Sources                 
Hit http://us.archive.ubuntu.com trusty-backports/restricted Sources           
Hit http://us.archive.ubuntu.com trusty-backports/universe Sources             
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Sources           
Hit http://us.archive.ubuntu.com trusty-backports/main amd64 Packages          
Hit http://us.archive.ubuntu.com trusty-backports/restricted amd64 Packages    
Hit http://us.archive.ubuntu.com trusty-backports/universe amd64 Packages      
Hit http://us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages    
Hit http://us.archive.ubuntu.com trusty-backports/main Translation-en          
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Translation-en    
Hit http://us.archive.ubuntu.com trusty-backports/restricted Translation-en    
Hit http://us.archive.ubuntu.com trusty-backports/universe Translation-en      
Fetched 1766 kB in 9s (189 kB/s)                                               
Reading package lists... Done
W: Failed to fetch http://nginx.org/packages/ubuntu/dists/trusty/InRelease  

W: Failed to fetch http://nginx.org/packages/ubuntu/dists/trusty/Release.gpg  Could not resolve 'nginx.org'

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

/etc/apt/sources.list这些是我添加到Nginx末尾的行:

deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx

答案1

问题是,虚拟专用服务器仅具有 IPv6 接口,并且当提出该问题时,官方 Nginx 包的位置不支持 IPv6。

我使用的托管公司免费提供 IPv6 接口,如果您需要 IPv4 接口,则需要额外收费(因为 IPv4 地址已不可用,所以他们试图节省它们)。

解决方案就是支付 IPv4 接口费用。实施 IPv4 接口后,更新工作顺利进行。

相关内容