8

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?

0

2 Answers 2

8

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.

2
  • 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, 2017 at 15:06
  • I am on Ubuntu 18.04 LTS and I found this: > Netplan is the default network management tool on Ubuntu 18.04, replacing the /etc/resolv. conf and /etc/network/interfaces configuration files that have been used to configure the network in the previous Ubuntu versions systemd-resolved is a service that provides DNS name resolution to local services and applications and it can be configured with Netplan, the default network management tool on Ubuntu 18.04 To check status: systemd-resolve --status | grep 'DNS Servers' -A2 linuxize.com/post/how-to-set-dns-nameservers-on-ubuntu-18-04
    – David
    May 10, 2020 at 6:15
6

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.

0

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