红联Linux门户
Linux帮助

apt-get: Could not resolve 'archive.ubuntu.com'解决方法

发布时间:2016-09-06 14:55:42来源:linux网站作者:peakguy
在使用Ubuntu搭建TFTP服务器的时候,新买的Linux服务器主机,在是还用atp-get的时候出现了apt-get: Could not resolve 'archive.ubuntu.com'的错误,一开始按照网上的说法,修改apt-get的源网址,添加了国内的一些网址资源以后还是不行,比如添加了以下的一些资源网址:
 
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main restricted
deb http://mirrors.ustc.edu.cn/ubuntu/ precise universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb http://mirrors.sohu.com/ubuntu/ precise universe
deb-src http://mirrors.sohu.com/ubuntu/ precise universe
deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb http://mirrors.sohu.com/ubuntu/ precise multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb http://mirrors.163.com/ubuntu/ precise universe
deb-src http://mirrors.163.com/ubuntu/ precise universe
deb http://mirrors.163.com/ubuntu/ precise-updates universe
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
deb http://mirrors.163.com/ubuntu/ precise multiverse
deb-src http://mirrors.163.com/ubuntu/ precise multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
 
至于怎么修改该文件,可以通过通过SSH Secure File Transfer软件打开目录/etc/apt下面的source.list文件通过记事本进行编辑,也就是将上面的内容添加到文件的后面。编辑如下图所示:
apt-get: Could not resolve 'archive.ubuntu.com'解决方法
但是添加完以上网址后,还是出现Could not resolve 'archive.ubuntu.com'的错误,这种原因其实是因为还缺少一个步骤,就是讲添加的这几个网址的网址和IP进行映射,修改/etc/目录下的host文件,用记事本打开,如下图所示:
apt-get: Could not resolve 'archive.ubuntu.com'解决方法
讲host文件中的网址找到其实际的IP地址,至于怎么通过网址找到实际的IP,可以百度一下,或者使用ip.chinaz.com进行查询,修改后的host文件如下图所示:
apt-get: Could not resolve 'archive.ubuntu.com'解决方法
 
不同时期的网址和IP对应关系是不一样的,上面的网址与IP对应关系在2016年9月5日的时候有效,如果实现请重新查询网址与IP的对应关系。
设置好以上步骤之后,执行命令sudo apt-get update和命令sudo apt-get upgrade。执行完之后,会更新目录,如下图所示:
apt-get: Could not resolve 'archive.ubuntu.com'解决方法
执行完上面的更新后,就会解决改问题了。
 
综上,主要就是2点:1、添加资源网站,2讲添加的资源网站和实际的IP做映射。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/23934.html