在使用networkmanager设置网卡时,会出现每次重启系统时DNS自动清零的问题,每次重启后都要重新设置DNS非常麻烦。
而nameserver的配置文件是 /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 202.102.152.3
# 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 202.102.152.3
重启后nameserver 202.102.152.3就被删除了。
由上面的# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
可以看出,resolv.conf是由resolvconf产生的。编辑vim /etc/resolvconf/resolv.conf.d/head 文件
显示与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 202.102.152.3
保存退出,
resolvconf -u
此时就可以正常上网了,重启后不用在重新设置DNS了。
# 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 202.102.152.3
保存退出,
resolvconf -u
此时就可以正常上网了,重启后不用在重新设置DNS了。