Score:0

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

tv flag

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.

Score:2
in flag

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 ...

Score:0
tv flag

As it turned out, quite similar thing that satisfies my needs can be done the other way around (just because domains don't overlap). The necessary functionality is in the dnsmasq itself and i can achieve what i want in the following way:

  1. Start systemd-resolved on 127.0.0.53

  2. Add necessary rules to dnsmasq.conf

    address = /banana.services/127.0.0.1
    address = /mango.services/127.0.0.1
    
  3. Finalize dnsmasq.conf with fallback servers of systemd-resolved and global dns

    server = 127.0.0.53
    server = 8.8.8.8
    server = 8.8.4.4
    server = 1.1.1.1
    
  4. Voila - now* the dnsmasq will first serve local overrides, then look into local DNS, and finally, if it returns empty-handed as well, will query the list of well-known DNS servers

* nsswitch.conf may require changing the order of resolution as well.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.