systemd-resolved does not query dns server for local domain

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

UPD2: Or you could just revert to dnsmasq as described here https://askubuntu.com/a/911432/692094


I got the same problem on Ubuntu 18.04, which also use systemd-resolved for DNS. Its default configuration does not resolve single-label hostnames or .local domain hostnames by DNS, but by LLMNR or mDNS respectively.

To make local single-label hostnames or .local domain hostnames resolved by DNS, I enabled the 3rd of the "Four modes of handling /etc/resolv.conf" described in the man page for systemd-resolved.service:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

A similar answer was given here. And again, for the reasoning behind the default, see poettering's reply in this bug report.


What worked for me after upgrating to 18.04 was to configure the file /etc/systemd/resolved.conf changing the Domains parameter to the domain (local or as in my case mydomain.local). I also changed the DNS parameter, but it seemed that it is not relevant, but I mention it just in case that is not true. For more information go to https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html.

Additionally I changed the avahi configuration (/etc/avahi/avahi-daemon.conf) to change the domain parameter inside the server section from local (the default) to something else as some people pointed out in this forum.

With the mentioned changes I can reach the machines using dotless names, for example, pinging to mycomputer the machine is contacted successfully. However, if I ping to mycomputer.mydomain.local it does not work, the FQDN is not resolved as expected.

Hoping this helps for some cases or lead to a more general solution.

Tags:

Dns

Networking