Bootstrap

ubuntu sudo apt-get update无法解析域名

问题

 sudo apt-get update时提示如下:

1195240275409c4b36ad8435e014e88a1ca.jpg

然后cat /etc/resolv.conf 查看dns server发现里面是空的。

解决办法:

1. 永久有效

sudo vi /etc/resolvconf/resolv.conf.d/base
在里面插入:
nameserver 8.8.8.8
nameserver 8.8.4.4

sudo resolvconf -u
cat /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 8.8.8.8
nameserver 8.8.4.4

2. 重启失效

vi /etc/resolv.conf添加如下内容
nameserver 8.8.8.8
nameserver 8.8.4.4
sudo /etc/init.d/networking restart

转载于:https://my.oschina.net/xgcode/blog/3028963

;