Ubuntu – How to configure local DNS lookup in Ubuntu 16.10

16.10dnsnetworking

I freshly installed Ubuntu 16.10 and rsync'd a backup of my previous home directory from kubuntu 16.04 to my new install. Things work well, but I have not been able to resolve local addresses despite much trial and error.

All networking seems to be working flawlessly. Internet browsing, DNS lookup of outside addresses, ssh, etc. are great. Locally, I can access machines via ssh with their addresses, but not their names. It all works fine in nautilus/samba, meaning WINS works. The single problem, it appears, is local network DNS. I have avahi-daemon installed and running, as it came with Ubuntu.

I've included some troubleshooting, using <<>> to shorten redundant or correctly working portions.

$ nmcli g
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled 

$ ping tendril8 << or tendril8.local >>
ping: tendril8: Name or service not known

$ ping gateway
PING gateway (192.168.1.1) 56(84) bytes of data.
64 bytes from gateway (192.168.1.1): icmp_seq=1 ttl=64 time=4.16 ms

$ ping askubuntu.com
PING askubuntu.com (151.101.129.69) 56(84) bytes of data.
64 bytes from 151.101.129.69 (151.101.129.69): icmp_seq=1 ttl=49 time=43.0 ms

$ nslookup askubuntu.com
Server:     127.0.1.1
Address:    127.0.0.1#53
<< followed by several IP addresses >>

$ nslookup tendril8 << or tendril8.local >>
Server:     127.0.1.1
Address:    127.0.0.1#53
** server can't find tendril8: NXDOMAIN

$ cat /etc/resolv.conf
# 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

$ ls -la /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Oct 15 19:30 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

$ cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files resolve [!UNAVAIL=return] mdns4_minimal dns [NOTFOUND=return]
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

Note: I've spent a great deal of time looking at "older" solutions, prior to Ubuntu switching to systemd.resolved in 16.10. They have not worked for me and I don't believe this to be a duplicate question to similar ones with prior Ubuntu configurations.

Best Answer

If I understand your question properly, you cannot resolve your local hostnames.

On that, I had the same problem with a fresh install of 16.10, and it turns out to be a known issue (https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624071) related to libnss-resolve in systemd.

The solution in my case was to review your /etc/nsswitch.conf file and note specifically how NSS resolves your hosts:

hosts: files resolve [!UNAVAIL=return] mdns4_minimal [NOTFOUND=return] dns myhostname

This logic appears to fail hostname resolution before even getting to mDNS.

Editing the hosts line back to a pre-16.10 release fixes this apparent logic error:

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

The included bug-report link suggests a future release of of the systemd package may eventually correct this problem.

Rich

Related Question