1. /etc/resolv.conf 文件记录了Linux下的DNS服务器, 但是这个文件在重启networking 或者计算机重启后会丢失.
2. 要解决这个问题可以安装 resolvconf这个软件.
-
apt-cache search resolvconf
-
apt-get install resolvconf
3. 添加配置文件
-
vim /etc/resolvconf/resolv.conf.d/base
-
#输入DNS
-
nameserver 8.8.8.8
-
nameserver 114.114.114.114
-
-
vim /etc/default/resolfconf
-
#输入
-
TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS=no
-
4. 执行命令
5. 然后重启networking ,发现/etc/resolv.conf还在,说明该方法有效.
-
service networking restart
6. 开机自启动.
-
systemctl enable resolvconf.service
7.
更多信息,请man resolvconf.
阅读(5079) | 评论(0) | 转发(0) |