如何在Ubuntu 16.10中配置本地DNS查找?

我刚刚安装了Ubuntu 16.10和rsync’d我以前的主目录的备份从kubuntu 16.04到我的新安装。 事情很好,但尽管有很多试验和错误,但我还是无法解决本地地址问题。

所有的网络似乎都完美无缺。 互联网浏览,外部地址的DNS查询,ssh等都很棒。 在本地,我可以通过ssh访问机器的地址,但不是他们的名字。 它在nautilus / samba中运行良好,这意味着WINS可以工作。 看来,唯一的问题是本地网络DNS。 我安装并运行了avahi-daemon,因为它附带了Ubuntu。

我已经包含了一些故障排除,使用<>来缩短冗余或正确工作的部分。

$ nmcli g STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN connected full enabled enabled enabled enabled $ ping tendril8 <> 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 <> $ nslookup tendril8 <> 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 

注意:在Ubuntu在16.10中切换到systemd.resolved之前,我花了很多时间查看“较旧”的解决方案。 他们没有为我工作,我不认为这是与以前的Ubuntu配置相似的重复问题。

如果我正确理解您的问题,则无法解析您的本地主机名。

在那个问题上,16.10的全新安装遇到了同样的问题,结果发现这是一个与libnss相关的已知问题( https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624071 ) – 解析systemd。

我的解决方案是查看您的/etc/nsswitch.conf文件,并具体说明NSS如何解析您的主机:

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

在进入mDNS之前,此逻辑似乎无法解析主机名。

将主机行编辑回16.10之前的版本修复了这个明显的逻辑错误:

 hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname 

包含的错误报告链接表明systemd包的未来版本可能最终纠正此问题。

丰富

另一种自动编辑/etc/nsswitch.conf解决方案是删除[ edit:并重新安装] libnss-resolve

 sudo apt purge libnss-resolve sudo apt install libnss-resolve 

我有一个全新的Ubuntu 17.04安装问题。 我选择在我的笔记本电脑上使用systemd-resolved切换到dnsmasq(名称服务器也使用dnsmasq)。 我按照如何禁用systemd-resolved中的步骤并使用dnsmasq解析DNS?