Ubuntu 17.04: systemd-resolved cannot use multiple purpose nameserver

systemd-resolved manages /etc/resolv.conf. But it cannot use multiple purpose nameserver.

1 Multiple purpose nameserver

My DHCP server provides the following two nameserver.

  • DNS server 192.168.11.2 resolves hiroom2.com domain name.
  • DNS server 192.168.11.1 resolves internet name.

In conclusion, 192.168.11.2 should support recursion query to 192.168.11.2 and DHCP server should provide only 192.168.11.2. But if 192.168.11.2 is down, cannot resolve internet name.

2 Other Linux's /etc/resolv.conf

Fedora 26's /etc/resolv.conf is the following. Other Linux and BSD is the same with it.

$ cat /etc/resolv.conf
# Generated by NetworkManager
search hiroom2.com
nameserver 192.168.11.2
nameserver 192.168.11.1

This will send query to 192.168.11.2 at first. If 192.168.11.2 cannot resolve name, this will send query to 192.168.11.1. I do not know if this is a correct behavior.

3 Ubuntu 17.10's /etc/resolv.conf

Ubuntu 17.10's /etc/resolv.conf is the following. systemd-resolved responds when sending query to 127.0.0.53.

# 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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

systemd-resolved recognizes multiple nameserver from DHCP server. systemd-resolved switch DNS server with message "Switching to DNS server …".

$ systemd-resolve --status
Global
<snip>
Link 2 (ens3)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.11.2
                      192.168.11.1
          DNS Domain: hiroom2.com

If 192.168.11.2 does not support recursion query, systemd-resolved will use only 192.168.11.2.

This cannot resolve internet name.

$ sudo journalctl --no-pager -u systemd-resolved -f
systemd-resolved[3077]: Switching to DNS server 192.168.11.2 for interface ens3.

If 192.168.11.2 supports recursion query to 192.168.11.1, systemd-resolved switches DNS server for random interval.

With enabling systemd debug log, switching from 192.168.11.2 to 192.168.11.1 is because systemd-resolved treats time of recursion query as timeout. I do not know why switching from 192.168.11.1 to 192.168.11.2.

This sometimes cannot resolve hiroom2.com domain name.

$ sudo journalctl --no-pager -u systemd-resolved -f
systemd-resolved[3077]: Switching to DNS server 192.168.11.2 for interface ens3.
systemd-resolved[3077]: Switching to DNS server 192.168.11.1 for interface ens3.
systemd-resolved[3077]: Switching to DNS server 192.168.11.2 for interface ens3.
systemd-resolved[3077]: Switching to DNS server 192.168.11.1 for interface ens3.

This switching behavior prevents using multiple purpose nameserver.

In conclusion, 192.168.11.2 should support recursion query to 192.168.11.2 and DHCP server should provide only 192.168.11.2.

But I hope that systemd-resolved supports behavior of other Linux.