公司的新上的伺服器用的都是最新的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