公司的新上的服务器用的都是最新的Ubuntu 12.04,同事跟我反映了一个问题,每次重启了之后,/etc/resolv.conf里面设置的nameserver就被清空了,很诡异
root@Ttpod:~# 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
root@Ttpod:~#
仔细看一下,也发现了问题
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
不要手动编辑这个文件,你做的改变将会被覆盖。
不知道是不是这样翻译,本人E文比较烂,理解的是这个意思。
我们改DNS一般都是在这里改的,我之前用Redhat。
为了防止系统重启之后,DNS设置被清空,我们要在网卡的配置文件里面改
root@Ttpod:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1
在里面加入 dns-nameservers DNS_ADDRESS
再重启,就不会被清空的了。
本文转自 gm100861 51CTO博客,原文链接:http://blog.51cto.com/gm100861/895579