Ubuntu: How do I Permanently configure the DNS server list in 16.04?



Question:

I've tried using network-admin. It has a list of DNS servers, including 127.0.0.1 and two that I put in. It always uses the 127 address first, no matter how many times I change it. The lists of files, hook scripts, etc, are confusing: where is the single configuration file for networking that I can modify to effect a permanent change?

I'm tired of asking my ISP's poor quality DNS server to serve my internet requests. I have no idea why Ubuntu repeatedly resets my configuration, or where the graphical interface stores this information -- until it's changed again. This is UNNECESSARILY confusing.

I checked network-admin gui an hour ago and it read, in order, 127.0.1.1 8.8.4.4 8.8.8.8 I moved the two 8.'s to the top, above 127; just checked it, now the first, which wasn't on the list before, is 192.168.1.254 -- which is my network routers lan-side address. Requests to this are routed to the internet; DNS requests here are automatically routed to att's DNS instead of Google's. This is demonstrated when there is a lookup error in FireFox browser it shows an error page from dnserrorassist.att.net

I really would like to have a single, static list of DNS servers, to be able to modify it at my will, and to set the lookup order in which they are used. Can i do that with Ubuntu (16.04)?


Solution:1

The correct answer for this question is:

  • go to the Network icon in the top panel

  • select Edit Connections

  • open the connection that you wish to modify ie: Wired Connection

  • select the IPV4 tab

  • set the Method to Automatic (DHCP) addresses only

  • in the DNS Servers field, enter a comma-separated list of your DNS servers

  • click the Save button

** do not edit your resolv.conf file


Solution:2

This is an old post at this point, but I had some additional information. If you are running a headless server then the following should come in helpful.

For DHCP Configurations: Modify /etc/network/interfaces. Under your interface (eth0, etc) add the following line:

dns-nameservers 123.123.123.123 # replace with wanted IP  

This only APPENDS a DNS server if your DHCP server is already configured to provide you one!!! To OVERRIDE the DHCP server's provided nameserver modify the following file.

/etc/dhcp/dhclient.conf:  supersede domain-name-servers 123.123.123.123 # replace with wanted DNS server  

You will then need to restart your network. Something like the following should do. # invoke-rc.d networking restart

Now if you view /etc/resolv.conf you should see only your nameserver(s).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »