开发者

Ubuntu报“无法解析域名cn.archive.ubuntu.com“问题解决办法

开发者 https://www.devze.com 2024-11-10 10:00 出处:网络 作者: sanqima
目录发现问题 1 查看Ubuntu的发行版本2 备份sources.list3 修改sources.list的权限4 填写Ubuntu镜像5 刷新apt源6 其他镜像6.1 阿里云的Ubuntu镜像6.2 清华的Ubuntu镜像6.3 中科大的Ubuntu镜像总结 发现问题
目录
  • 发现问题 
  • 1 查看Ubuntu的发行版本
  • 2 备份sources.list
  • 3 修改sources.list的权限
  • 4 填写Ubuntu镜像
  • 5 刷新apt源
  • 6 其他镜像
    • 6.1 阿里云的Ubuntu镜像
    • 6.2 清华的Ubuntu镜像
    • 6.3 中科大的Ubuntu镜像
  • 总结 

    发现问题 

    今天在Ubuntu系统上,使用sudo apt update命令,进行更新时,弹出"无法解析域名 cn.archive.ubuntu.com"问题,如图(1)所示:

    Ubuntu报“无法解析域名cn.archive.ubuntu.com“问题解决办法

    图(1) 弹出"无法解析域名 cn.archive.ubuntu.com" 错误

    出现这种现象的原因: cn.archive.ubuntu.com这个网站的镜像资源不稳定,dns经常解析出错,需要改成稳定性好、速度快的Ubuntu镜像,,比如,

    • 163镜像(http://mirrors.163.com/ubuntu/)、
    • 清华源镜像(https://mirrors.tuna.tsinghua.edu.cn/ubuntu/)
    • 中科大镜像(https://mirrors.ustc.edu.cn/ubuntu/)
    • 阿里云镜像(http://mirrors.aliyun.com/ubuntu/)

    这里推荐163镜像(http://mirrors.163.com/ubuntu/),解决步骤如下:

    1 查看Ubuntu的发行版本

    查看Ubuntu的发行版本,命令如下:

    lsb_release -a
    

    由图(2) 可知,当前系统的发行版本是bionic,则Ubuntu的apt源镜像要选择bionic版本。

    注意:镜像源的版本,要与当前系统的发行版本(代号版本)保持一致。

    Ubuntu报“无法解析域名cn.archive.ubuntu.com“问题解决办法

    图(2) 查看Ubuntu的发行版本(即代号,昵称)

    2 备份sources.list

    sudo  cp  /etc/apt/sources.list    /etc/apt/sources.list.bak
    

    3 修改sources.list的权限

    su root
    chmod 666 /etc/apt/sources.list
    

    4 填写Ubuntu镜像

    将原来的sources.list文件里的内容清空,然后,填入如下的163的apt源(镜像):

    deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
    

    5 刷新apt源

    sudo apt-get update
    sudo apt-get upgrade
    

    6 其他镜像

    6.1 阿里云的Ubuntu镜像

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricjavascriptted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    

    6.2 清华的Ubuntu镜像

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe mjavascriptultiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubun编程tu/ bionic-updates main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    

    6.3 中科大的Ubuntu镜像

    deb hjsttps://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src phphttps://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

    总结 

    到此这篇关于Ubuntu报“无法解析域名cn.archive.ubuntu.com“问题解决办法的文章就介绍到这了,更多相关Ubuntu 无法解析域名cn.archive.ubuntu.com内容请搜索编程客栈(www.devze.com)以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程客栈(www.devze.com)!

    0

    精彩评论

    暂无评论...
    验证码 换一张
    取 消