歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Ubuntu 12.04重啟清空/etc/resolv.conf裡nameserver的設置如何解決

Ubuntu 12.04重啟清空/etc/resolv.conf裡nameserver的設置如何解決

日期:2017/3/3 15:57:14   编辑:關於Linux

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

URL:http://www.bianceng.cn/OS/Linux/201410/46059.htm

為了防止系統重啟之後,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

再重啟,就不會被清空的了。

Copyright © Linux教程網 All Rights Reserved