1

Each time I restart my computer , the nameserver change automatically , and it changed to 127.0.0.1 .

Hence in order to connect to the internet I need to edit the resolv.conf file . After each restart I find my resolv.conf file as

nameserver 127.0.0.1

then I need to edit the file to

nameserver 8.8.8.8
nameserver 8.8.4.4

What is the possible reason behind this and how can I solve it ? My OS is ubuntu 14.04

aroSuv
  • 23
  • 3
  • For the record, blame NetworkManager and dnsmasq. 127.0.0.1 will point to dnsmasq which in turn handles caching of DNS lookups and also handles relaying out to other name servers (such as 8.8.8.8 and 8.8.4.4 or whatever DHCP gives to your system). Not using NetworkManager is a start but if you have wifi, you may be screwed there. – Thomas Ward Oct 29 '15 at 04:29
  • Is this an Ethernet or wireless connection you primarily use? – Thomas Ward Oct 29 '15 at 04:30
  • Duplcate [How do I include lines in resolv.conf that won't get lost on reboot?](http://askubuntu.com/questions/157154/how-do-i-include-lines-in-resolv-conf-that-wont-get-lost-on-reboot/310407#310407) – astrajingga Oct 29 '15 at 08:48

1 Answers1

0

Personally , when it comes to setting custom nameserver I prefer using supersede option in /etc/dhcp/dhclient.conf file. When you connect to access point , the router sends some infomation to your machine, including what DNS it should be using. supersede takes that option and replaces that setting with whatever you provide. More precisely, I'd use supercede domain-name-servers 8.8.8.8;

Here's the example of my file's top part. Notice where I set that option

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;
Sergiy Kolodyazhnyy
  • 103,293
  • 19
  • 273
  • 492