1

I'm trying to add a nameserver to the top of my resolv.conf file on Ubuntu 19.10. I want to always have the nameserver 127.0.0.1 at the top.

I have created a created a new file called:

/etc/NetworkManager/conf.d/10-dhcp.conf

and in that file I have added:

[main]
dhcp=dhclient

And that kinda worked when rebooting the computer, however when the laptop goes to sleep the resolv.conf file no longer has my custom name sever prepended to the top of the file. What is the best way to get this change to stick in Ubuntu 19.10?

My /etc/systemd/resolved.conf file looks like this:

[Resolve]
DNS=127.0.0.1
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
DNSStubListener=no
#ReadEtcHosts=yes

My /etc/resolv.conf file looks like this:

nameserver 127.0.0.53
options edns0
search lan

And the permissions on my /etc/resolv.conf file look like this:

lrwxrwxrwx 1 root root 39 Dec 6 08:09 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

Output of systemd-resolv --status

 > systemd-resolve --status
Global
       LLMNR setting: no
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 127.0.0.1
         DNS Servers: 127.0.0.1
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
11
  • I'm not sure that adding 127.0.0.1 is the right thing to do, let alone creating 10-dhcp.conf. Do you have a DNS Server running on your computer? You might look at /etc/systemd/resolved.conf.
    – heynnema
    Dec 7 '19 at 17:15
  • I have DNSmasq setup so I can resolve local domains.
    – kaptk2
    Dec 7 '19 at 17:42
  • If you check the file I specified, you might use the DNS=, and also change the DNSStubListener= to NO... as both dnsmasq and the systemd resolver will try to use port 53.
    – heynnema
    Dec 7 '19 at 17:51
  • I've added DNS=127.0.0.1 and changed DNSStubListener=no and am not seeing anything changed in my /etc/resolv.conf file other than no DNS is working with those changes.
    – kaptk2
    Dec 8 '19 at 20:21
  • Did you install dnsmasq or dnsmasq-base?
    – heynnema
    Dec 8 '19 at 20:29
0

Remove /etc/NetworkManager/conf.d/10-dhcp.conf.

Edit /etc/systemd/resolved.conf and change:

sudo -H gedit /etc/systemd/resolved.conf # edit file

This:

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes
#ReadEtcHosts=yes

To this:

[Resolve]
DNS=127.0.0.1
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
DNSStubListener=no
#ReadEtcHosts=yes

reboot # reboot computer

systemd-resolv --status # check DNS servers

Correctly now shows 127.0.0.1 as the default DNS servers, so it should now work with your dnsmasq installation.

12
  • When using this solution I get no DNS resolution at all. My /etc/resolv.conf file contains no reference to 127.0.0.1
    – kaptk2
    Dec 11 '19 at 1:15
  • 127.0.0.1 does show up in systemd-resolve --status. What does dpkg -l resolv* return?
    – heynnema
    Dec 11 '19 at 3:05
  • Edit the /etc/systemd/resolved.conf file, and temporarily change 127.0.0.1 to 8.8.8.8, reboot, then do systemd-resolve --status | grep -i dns and see if it returns 8.8.8.8. See if host www.ebay.com works.
    – heynnema
    Dec 11 '19 at 3:09
  • @kaptk2 status please...
    – heynnema
    Dec 11 '19 at 22:33
  • Hi, I have made the requested changes to /etc/systemd/resolved.conf and when I do a system-resolve --status | grep -i dns I do see DNS Servers: 8.8.8.8 output however DNS resolution does not work. I get a "connection timed out; no server could be reached" error when trying to do a host lookup on www.ebay.com. No changes within my /etc/resolv.conf happen
    – kaptk2
    Dec 11 '19 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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