4

This question already has an answer here:

I have been trying to change my dns to 8.8.8.8 8.8.4.4 but don't seem to be able to do it.

In /etc/resolv.conf I have

# 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

In /etc/resolvconf/resolv.conf.d/base I added

nameserver 8.8.8.8
nameserver 8.8.4.4

and reloaded with sudo resolvconf -u

but nothing changes in /etc/resolv.conf

If I misspell something in /etc/resolvconf/resolv.conf.d/base for example adding ameserver 8.8.8.8 and reloading cat /etc/resolv.conf now shows.

# 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
ameserver 8.8.8.8

What should I be doing to change the dns and how can I check if it has worked?

marked as duplicate by David Foerster, user117103, user364819, Pilot6, Eric Carvalho Jun 6 '17 at 16:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What is the output of file /etc/dhcp/dhclient.conf. – Ravexina Jun 4 '17 at 9:43
  • /etc/dhcp/dhclient.conf: ASCII text – Qwertie Jun 4 '17 at 9:44
  • First remove the lines you add to /etc/resolvconf/resolv.conf.d/base then add this line: prepend domain-name-servers 8.8.8.8 to /etc/dhcp/dhclient.conf somewhere under "option" line... then use ifdown and ifup to bring your connection down and up. after that check /etc/resolv.conf. – Ravexina Jun 4 '17 at 9:48
  • I can't seem to use ifdown Unknown interface enp3s0 but thats what ifconfig says my interface is called – Qwertie Jun 4 '17 at 9:56
  • 1
    You are much better off to change DNS in Network Manager. – chili555 Jun 4 '17 at 11:03
5

To expand on the other answer here, and to clear up some confusions here, if you are using Network Manager to manage your connections, it also includes a small version of dnsmasq. This is what the 127.* address is in your resolv.conf - the IP address of localhost, where dnsmasq has bound to.

Network Manager, when configured with the DNS servers, will tell dnsmasq what DNS servers to relay requests to.

If you set 8.8.8.8 as your DNS server in Network Manager's settings, dnsmasq will forward all requests that aren't cached to 8.8.8.8 for actual resolving, while your computer sends DNS requests directly to dnsmasq for handling.

Confusing, I know, but you can't rely on resolv.conf to show the DNS servers in use when you are using Network Manager to manage the connections.

  • +1 Got it also updated my answer ;) – Ravexina Jun 4 '17 at 13:05
  • This really answered my questions, I saw a lot of posts online about how /etc/resolv.conf contains your dns server but it wasn't changing when I went through the usual methods. – Qwertie Jun 4 '17 at 15:06
3

First revert everything we did in comments.

Use:

$ nmcli device 

to get a status of Network manager:

DEVICE  TYPE      STATE        CONNECTION 
enp3s0  ethernet  connected    myConnection

So my interface is enp3s0 and my connection name is myConnection.

I can check what DNS server my connection is using:

$ nmcli -f IP4.DNS connection show myConnection

For you I guess it's going to show:

ipv4.dns:                               127.0.0.1

Now let's set you desired DNS serves:

nmcli connection modify myConnecion ipv4.dns "8.8.8.8, 8.8.4.4"

After all reload the connection:

nmcli connection down myConnecion
nmcli connection up myConnecion

Then check /etc/resolv.conf:

cat /etc/resolv.conf

If it still says that you are using 127.0.0.1 as your DNS server then there is a high chance you're using "dnsmasq", to make sure run:

sudo ss -pln sport = 53

You should get dnsmasq name as a process listening on port 53, so every thing is fine and you are using correct DNS name serves, 127.0.0.1 is just a layer between you and the servers you set.

If you want to actually see "8.8.8.8" in /etc/resolv.conf then you should disable "dnsmasq".

Open this file :

/etc/NetworkManager/NetworkManager.conf

Change dns=dnsmasq to #dns=dnsmasq.

Finally:

sudo systemctl restart NetworkManager

Now check /etc/resolv.conf again.

  • I did all that and grep shows ipv4.dns: 8.8.8.8,8.8.4.4 but /etc/resolv.conf shows nameserver 127.0.0.1 – Qwertie Jun 4 '17 at 11:20
  • What is the output of : dig google.com | grep -i server: – Ravexina Jun 4 '17 at 11:29
  • ;; SERVER: 127.0.0.1#53(127.0.0.1) – Qwertie Jun 4 '17 at 11:42
  • Are you sure that you are using the correct connection? is there any other connection up? – Ravexina Jun 4 '17 at 11:54
  • Isn't 127.0.0.1#53 normal for systems that use dnsmasq? it doesn't mean that queries aren't being forwarded to your chosen server – steeldriver Jun 4 '17 at 12:09

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