Linux服务器配置镜像,暂时不能解析域名
报错解决
DSN配置参考来源:Blog
在使用sudo apt-get update
时,由于默认的下载网站地址在国外,会出现下载失败,这里需要配置国内镜像
一、镜像配置
将/etc/apt/sources.list
文件进行备份sudo cp /etc/apt/sources.list ./sources_copy.list
,sudo vim /etc/apt/sources.list
打开文件,将之前的东西删了,把清华的镜像复制进去
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
修改后更新
sudo apt-get update
sudo apt-get upgrade
1.继续报错
出现如下类型报错,说明DNS
没有配置好
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-updates/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-backports/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-security/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/focal-proposed/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/InRelease 暂时不能解析域名“developer.download.nvidia.com”
W: 无法下载 https://mirrors.tuna.tsinghua.edu.cn/nvidia-cuda/ubuntu2004/x86_64/InRelease 暂时不能解析域名“mirrors.tuna.tsinghua.edu.cn”
W: 无法下载 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu/dists/focal/InRelease 暂时不能解析域名“ppa.launchpad.net”
2.解决方法
sudo vi /etc/resolv.conf
在配置中加入:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
#这里用的是阿里云的DNS服务器
nameserver 223.5.5.5
nameserver 223.6.6.6