当前位置: 移动技术网 > 科技>操作系统>Linux > Ubuntu 12.04解决重启后resolv.conf清空的问题

Ubuntu 12.04解决重启后resolv.conf清空的问题

2019年05月30日  | 移动技术网科技  | 我要评论
这跟以前用rht系的 情况是完全不一样的:

在google上搜了一下,发现这里面还真有些奥妙:

1 /etc/resolv.conf 其实是一个link

它其实指向的是 /run/resolvconf/resolv.conf

2 ubuntu 有一个 resolvconf 服务,如果重启它,那么 /etc/resolv.conf 的内容会被修改成默认的样子

所以 不能直接修改 /etc/resolv.conf

3 如果想自己定义 nameserver,那么有以下2个办法:

a 在网卡的配置文件里面加:

iface eth0 inet static
address 192.168.3.3
netmask 255.255.255.0
gateway 192.168.3.1
dns-nameservers 192.168.3.45 192.168.8.10
dns-search foo.org bar.com

b 修改 resolvconf服务的配置文件: /etc/resolvconf/resolv.conf.d/base

这样,在机器重启或 resolvconf 服务重启 都可以保证配置会写到/etc/resolv.conf 里面
其实 /etc/resolv.conf 里面一直都有提示,只是自己没注意看:
"do not edit this file by hand -- your changes will be overwritten"
关于 resolvconf 服务更多信息,可以用man查看:man resolvconf

暂时我还没有找到能直接 刷新 /etc/resolv.conf 内容的命令,只能是重启 resolvconf 服务

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网