resolv.conf & systemd-resolved: query next server on domain not found responses

I'm trying to build a simple cascade DNS resolution algorithm for my laptop:

  • Query the servers provided by DHCP
  • Not found / failed? Query 8.8.8.8 and it's friends
  • Not found / failed? Query local dnsmasq on 127.A.B.C

Currently it seems that next server is only requested if previous one has failed one way or another, but if it has replied with an empty reply, the resolution process stops.

Is it possible to force Linux-powered machine to do it the cascade way described above either via kernel mechanisms or systemd-resolved? It's surely possible by routing requests through dnsmasq (setting systemd-resolved in the first server= directive to forward query to DHCP-provided servers), but I'd prefer going with less messy way that would keep as much of my distro intact as possible.


Unfortunately this is just not how DNS works. The only time other servers will be queried is when the previous server defined is not responding. ANY response, even if that response is NXDOMAIN, is a response. Even a response of Query Denied is a response ...