升级到 17.04 后,我无法再解析本地网络 (silvesternet.local) 中的地址。我收到以下回复:
$ systemd-resolve edgerouter
edgerouter: resolve call failed: No appropriate name servers or networks for name found
Run Code Online (Sandbox Code Playgroud)
在日志中,只有与此查找相关的事务超时报告。
我使用 Wireshark 来嗅探网络流量,它似乎甚至没有尝试查找名称。没有任何 dns 流量。查找另一个外部域工作正常。
围绕同一主题的许多问题都提到更改 nsswitch.conf,但这似乎并没有解决任何问题。我目前的设置是:
hosts: files mdns4_minimal dns [NOTFOUND=return] resolve [!UNAVAIL=return] mdns4
Run Code Online (Sandbox Code Playgroud)
ish*_*est 17
I believe this is by design.
Ubuntu 17.04 has switched to systemd-resolved for name resolution and it uses only LLMNR (multicast name lookup) for single-label names resolution. See this link for details: https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
For the reasoning behind this decision check out poettering's reply in this bug report: https://github.com/systemd/systemd/issues/2514
UPD: This issue can be worked around by using a domain for local network. If network interface is configured (either manually or by DHCP) to use a search domain then systemd-resolved will add this domain to single-label names and then look them up via unicast DNS.
Obviously the local DNS server should be reconfigured to recognise these domain. In case of dnsmasq that reads local host-to-IP pairs from /etc/hosts it can be accomplished by adding following instructions to dnsmasq.conf:
domain=mydomain.net
local=/mydomain.net/
expand-hosts
Run Code Online (Sandbox Code Playgroud)
UPD2: Or you could just revert to dnsmasq as described here https://askubuntu.com/a/911432/692094
小智 13
我在 Ubuntu 18.04 上遇到了同样的问题,它也将 systemd-resolved 用于 DNS。它的默认配置不是通过 DNS 解析单标签主机名或 .local 域主机名,而是分别通过 LLMNR 或 mDNS。
为了使 DNS 解析本地单标签主机名或 .local 域主机名,我启用了systemd-resolved.service 手册页中描述的“四种处理 /etc/resolv.conf 模式”中的第三种:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)
这里给出了类似的答案。同样,对于默认背后的原因,请参阅此错误报告中的诗人回复。