执行apt-get update出错:

root@dbserver1:/etc/apt/sources.list.d# apt-get update
错误:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
  暂时不能解析域名“security.ubuntu.com”
错误:2 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial InRelease
  暂时不能解析域名“ppa.launchpad.net”
错误:3 http://cn.archive.ubuntu.com/ubuntu xenial InRelease
  暂时不能解析域名“cn.archive.ubuntu.com”
错误:4 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease
  暂时不能解析域名“cn.archive.ubuntu.com”
错误:5 http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease
  暂时不能解析域名“cn.archive.ubuntu.com”
正在读取软件包列表... 完成
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/xenial/InRelease
 暂时不能解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease
 暂时不能解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://cn.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease
 暂时不能解析域名“cn.archive.ubuntu.com”
W: 无法下载 http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease
 暂时不能解析域名“security.ubuntu.com”
W: 无法下载
http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu/dists/xenial/InRelease
 暂时不能解析域名“ppa.launchpad.net”
W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。

 

解决方法:

这时候会发现ping www.baidu.com也ping不通,说明dns有问题。

修改dns:

sudo vi /etc/resolvconf/resolv.conf.d/base(这个文件默认是空的)

在里面插入:
nameserver 8.8.8.8

如果有多个DNS就一行一个

 

修改好保存,然后使其生效

sudo resolvconf -u


友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信