0

I'm getting dns failures on some of the servers with Ubuntu Server 17.10 or 18.01. I can't resolve addresses unless I go direct to the nameservers (ie with dig @1.2.3.4 ...) It can't resolve the simplest of queries:

$ host localhost
;; connection timed out; no servers could be reached

/etc/nsswitch.conf:

hosts:          files dns

/etc/resolve.conf

nameserver 127.0.0.53
search xx.uk xxx

netstat output:

$ netstat -pluten
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      102        209799     7876/systemd-resolv 
tcp        0      0 192.168.x.1:53        0.0.0.0:*               LISTEN      0          45394      2673/dnsmasq        
tcp        0      0 127.0.0.1:7030          0.0.0.0:*               LISTEN      0          26916      3236/docker-proxy   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          23759      1925/sshd           
tcp6       0      0 :::7946                 :::*                    LISTEN      0          48402      2076/dockerd        
tcp6       0      0 :::22                   :::*                    LISTEN      0          23761      1925/sshd           
udp        0      0 0.0.0.0:4789            0.0.0.0:*                           0          26906      -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           102        209798     7876/systemd-resolv 
udp        0      0 192.168.x.1:53        0.0.0.0:*                           0          45393      2673/dnsmasq        
udp        0      0 0.0.0.0:67              0.0.0.0:*                           0          45390      2673/dnsmasq        
udp        0      0 10.x.x.x:68          0.0.0.0:*                           101        2702       7218/systemd-networ 
udp6   22592      0 :::7946                 :::*                                0          48403      2076/dockerd 

Yet systemd-resolve is working:

$ systemd-resolve localhost
localhost: 127.0.0.1%lo
           ::1%lo

-- Information acquired via protocol DNS in 201.5ms.
-- Data is authenticated: yes

There's no output from systemd-resolved even in debug when making requests

  • Is resolv.conf a symlink to /run/systemd/resolve/stub-resolv.conf ? Otherwise it is possible the libc resolver might be confused... – Mathieu Trudel-Lapierre May 10 '18 at 19:55
  • Yes its a symlink to /run/systemd/resolve/stub-resolv.conf If I modify it to point to one of my nameservers, resolution works. – Richard Collins May 11 '18 at 7:20
1

I do not have any advice on how to fix systemd-resolved's stub DNS responder properly, but I can suggest a workaround:

  1. Enable nss-resolve for applications that use NSS
  2. Tell applications that do not use NSS to contact upstream nameservers directly

For (1), change your /etc/nsswitch.conf:

hosts: files resolve [!UNAVAIL=return] dns

For (2), link /etc/resolv.conf to /run/systemd/resolve/resolv.conf.

1

The simple workaround if you know for sure what DNS server would you like to use is just add them to /etc/systemd/resolved.conf. This works for me:

sudo vi /etc/systemd/resolved.conf

Uncomment the line #DNS= and add your preferred DNS servers (space separated).

DNS=8.8.8.8 8.8.4.4

Then do:

sudo systemctl restart systemd-resolved

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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