重新启动时名称服务器发生变化

重新启动时名称服务器发生变化

每次我重新启动计算机时,名称服务器都会自动更改,并更改为 127.0.0.1。

因此,为了连接到互联网,我需要编辑 resolv.conf 文件。每次重启后,我都会发现我的 resolv.conf 文件如下

nameserver 127.0.0.1

然后我需要编辑文件以

nameserver 8.8.8.8
nameserver 8.8.4.4

这背后的可能原因是什么?我该如何解决?我的操作系统是 ubuntu 14.04

答案1

就我个人而言,在设置自定义名称服务器时,我更喜欢使用文件supersede中的选项/etc/dhcp/dhclient.conf。当您连接到接入点时,路由器会向您的机器发送一些信息,包括它应该使用的 DNS。supersede采用该选项并用您提供的任何内容替换该设置。更准确地说,我会使用supercede domain-name-servers 8.8.8.8;

以下是我的文件顶部的示例。请注意我设置该选项的位置

xieerqi:$ cat /etc/dhcp/dhclient.conf  | head -n 30                            
# Configuration file for /sbin/dhclient, which is included in Debian's
#   dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
supersede domain-name-servers 208.67.220.220; ######  <-------- 
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers,
    dhcp6.fqdn, dhcp6.sntp-servers;
#require subnet-mask, domain-name-servers;
#timeout 60;

相关内容