问题
sudo apt-get update时提示如下:
然后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