Ubuntu – DNS resolv config

resolv.confresolvconf

Let me narrate you my small story:

So right now, I am using an Ubuntu 16.04 LTS distribution in my lab.
After installing Ubuntu, I tried just check my Internet access by googling.
However that was impossible. So firstly I try to ping Google's server:

ping 8.8.8.8

This first ping was successful. So secondly I try to ping yahoo site:

ping yahoo.com

The answer was that the name was unknown so I decide to check the resolv.conf
file in /etc:

# 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 127.0.0.1
search <www.some-sites>

The problem is the nameserver. My collaborators told me that the have copied some lines in /etc/resolvconf/resolv.config.d/base:

domain bla.bla
search <www.some-sites>
nameserver 111.222.3333.4444
nameserver 555.666.7777.8888

They proposed me to reboot or just run the following commands

resolvconf --enable-updates
resolvconf -u

When I checked /etc/resolv.conf it was again the same as that beginning

 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 127.0.1.1
search <www.some-sites>

So how I can input the domain and my two new specific nameservers???
I don't really know hot to configure interfaces and if it is possible.
I cannot also understand why this happened since base is a file that should be copied into resolv.conf file. Could you explain me why that error happened?

Thank you

Best Answer

NetworkManager is the program which (via the resolvconf utility) inserts address 127.0.1.1 into resolv.conf. NM inserts that address if an only if it is configured to start an instance of the dnsmasq program to serve as a local forwarding nameserver. That dnsmasq instance listens for queries at address 127.0.1.1.

If you wish to see witch DNS you use currently type command

nmcli device show <interfacename> | grep IP4.DNS

You can set different DNS param for each connection

If you do not want to use a local forwarding nameserver then configure NetworkManager not to start a dnsmasq instance and not to insert that address. In /etc/NetworkManager/NetworkManager.conf comment out the line dns=dnsmasq

sudo nano /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

and restart the NetworkManager service.

sudo systemctl restart network-manager

In this mode, NetworkManager updates /etc/resolv.conf (still via resolvconf) to include the nameserver addresses NetworkManager has for active connections.

If you want to disable the resolvconf mechanism for updating resolv.conf and just use a static resolv.conf file, do the following.

sudo rm -f /etc/resolv.conf  # Delete the symbolic link
sudo nano /etc/resolv.conf   # Create static file

# Content of static resolv.conf
nameserver 8.8.4.4
nameserver 8.8.8.8