问题描述
我升级到Ubuntu 17.04,现在似乎在Ubuntu 16.10中首次引入了new DNS resolver mechanism。
我现在有50%的时间遇到DNS查找失败。对nslookup的所有其他调用均失败,其中一半的调用可以解决问题,一半的调用可以解决此问题:
watch -n 1 nslookup google.com
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find google.com: SERVFAIL
据我了解,DNS服务器IP地址现在用于表示systemd-resolved,它会进行某种元查找以避免慢速的DNS查询(或其他)。我在过去一周升级到17.04的两台计算机上看到了完全相同的行为。
知道这里存在什么问题以及解决该问题的正确方法吗?
升级之前一切正常(从16.04或16.10起,抱歉,我不记得是哪个)。我认为17.04是LTS发行版,但现在我看到我跳枪了,直到4月份才被认为是稳定的。所以…我在这里。
还要注意的是…浏览器似乎没有出现问题,但是nslookup,ping,git等确实存在问题。
最佳回答
截至2017-04-18,Ubuntu 17.04无法解析具有DNSSEC支持的DNS服务器。使用此守护程序禁用DNSSEC:
sudo mkdir -p /etc/systemd/resolved.conf.d
printf "[Resolve]\nDNSSEC=no\n" | sudo tee /etc/systemd/resolved.conf.d/no-dnssec.conf
如果您对resolvconf感到困惑,可以选择重新配置它(说“是,准备/etc/resolve.conf以进行动态更新?”):
sudo dpkg-reconfigure resolvconf
重新启动systemd-resolved:
sudo systemctl restart systemd-resolved
您的DNS应该开始工作。您可以通过尝试systemd-resolve www.google.com
并查看响应来进行检查。
次佳回答
我一直在systemd-resolved和手动/etc/resolv.conf管理之间来回切换,但尚未发现systemd DNS解析器机制稳定。
显然在Ubuntu 16.10中至少有一个libnss bug,并且显然仍在17.04中。自从Ubuntu 16.10开启systemd-resolved以来,就有很多人遇到DNS问题,其中一种分析是here,另一种是here。在我用Google的DNS服务器手动改写/etc/resolv.conf之前,它们对我都不起作用。
nameserver 8.8.8.8 << or another if you don't trust google
nameserver 8.8.4.4
如果您不需要动态DNS配置,则这是perfectly valid solution。只要确保您停止并禁用systemd-resolved:
sudo systemctl disable systemd-resolved.service
sudo service systemd-resolved stop
第三种回答
Ubuntu 17.04和其他发行版都在拥抱systemd,其中包括systemd-resolved,它使用户经受相当大的heavy-handed DNS分辨率。
-
如SjB回答中所述,DNSSEC支持可能会引起问题。
-
systemd-resolved对所有DNS解析器执行ping操作,以便它可以最快地使用。在更复杂的环境中,这可能会导致VPN等问题。
-
DNS服务器证书已通过验证,如果我的时钟偏斜,我会出错。
我认为这不一定是一个坏的变化,只是很多变化。当我了解更多信息时,我将尝试更新和扩展此答案。
第四种回答
简单地说,您只需要在/etc/systemd/resolved.conf的[Resolve]部分中包含”DNSSEC=no”行。
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1682499/