ubuntu更新源解决方法

目录

 

错误信息

法1:只修改/etc/hosts文件

步骤1

步骤2

法2:添加国内源并修改/etc/hosts文件

步骤1

步骤2


错误信息

sudo apt-get update
错误信息:
    ......
    Could not resolve 'archive.ubuntu.com'  
    ......
    Could not resolve 'security.ubuntu.com'
    ......
    Could not resolve 'cn.archive.ubuntu.com'

法1:只修改/etc/hosts文件

步骤1

   查找域名对应的ip地址。以下几个“IP地址查询”网址都可以:
    http://ip.tool.chinaz.com    
    http://mip.chinaz.com
    http://ip.chinaz.com

示例:

ubuntu更新源解决方法

步骤2

    将域名和ip对应关系添加到/etc/hosts(如果查到多个ip,写一个就可以)
格式示例:
91.189.88.149 archive.ubuntu.com
91.189.88.149 security.ubuntu.com
91.189.91.23  cn.archive.ubuntu.com

127.0.0.1       localhost
127.0.1.1       liu

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

法2:添加国内源并修改/etc/hosts文件

步骤1

添加国内源

    /etc/apt/sources.list中是源的地址,形如:deb http://security.ubuntu.com/ubuntu bionic-security universe
    将http://security.ubuntu.com/ubuntu 换成国内的网址即可.
    国内的网址有。
    http://mirrors.163.com/ubuntu/      (网易)
    http://mirrors.sohu.com/ubuntu/            (搜狐)
    http://mirrors.aliyun.com/ubuntu/        (阿里云)
    http://ubuntu.mirrors.org.cn/                (ubuntu官方上海源)
    http://mirrors.yun-idc.com/ubuntu/    (首都在线科技)
    其他网址见:https://wiki.ubuntu.org.cn/源列表

步骤2

修改/etc/hosts文件
    方法见法1