override dns nameserver
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??
Solution 1:
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.
Solution 2:
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; }