2

i wish to set higher priority for my dns nameservers, or override the ones that are being set by the dhcp server. no matter which approach i took, nslookup never displays the right dns nameserver.

please see the snippet below.

$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

resolvconf:

$ cat /etc/resolvconf/resolv.conf.d/base 
nameserver 208.67.222.222
nameserver 208.67.220.220
$ sudo resolvconf --enable-updates
$ sudo resolvconf -u
$ nslookup
> server
Default server: 127.0.1.1
Address: 127.0.1.1#53

dhcp:

$ tail -n 1 /etc/dhcp/dhclient.conf 
supersede domain-name-servers 208.67.222.222, 208.67.220.220;
$ sudo service networking restart
$ nslookup
> server
Default server: 127.0.1.1
Address: 127.0.1.1#53

how it can be done??

  • The DNS server nslookup is using is the one in your system, which is then using (or should be using) 208.67.222.222 and 208.67.220.220. See this about 127.0.1.1. – saiarcot895 Jun 8 '14 at 17:38
  • @saiarcot895, how do i verify that this is indeed the case? do i have to monitor the communication packets? – MrRoth Jun 8 '14 at 18:35
  • «nslookup never displays the right dns nameserver» It displays your own computer, which you configured to use OpenDNS... If this is not right, what would be the right one? – Andrea Lazzarotto Sep 9 '14 at 15:27
  • You could have simply added your dns to supersede domain-name-servers 208.67.222.222, 208.67.220.220; in dhclient.conf – Sergiy Kolodyazhnyy Apr 11 '15 at 1:30
  • This question is different from the flagged duplicated question. The duplicate question doesn't have any answers that work for the OP of that question. He checkmarked what he thought was the best answer, but commented at the same time that the answer doesn't work. This OP's question is about the name server resolve. He showed his attempt for using configuring his /etc/resolvconf package. The answer provides the crutial step he mentioned. His changes needs to be in head, not base. – L. D. James Nov 9 '17 at 19:38
8

Add a header to your resolvconf configuration file. Create or edit the file, "/etc/resolvconf/resolv.conf.d/head". Add your preference to it.

/etc/resolvconf/resolv.conf.d/head:

# 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


nameserver 8.8.8.8
search [yourpreference.com]

Restart your networking service, rebooting is the surest way to restart it.

  • @MrRoth The comment in the head file does not apply to the file itself, but the composite /etc/resolv.conf that is generated by concatenating the fragments. – Lars Viklund Dec 10 '14 at 15:25
0

See https://askubuntu.com/a/63163/267945 - much better solution:

If you want to override or append to the name servers suggested by the DHCP server, you can configure this in /etc/dhcp/dhclient.conf, eg:

interface "eth0" {
    prepend domain-name-servers 10.0.0.2;
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.