Score:0

How to split DNS resolution based on the target domain?

cn flag
WoJ

Note: I read two other questions (here and here) that address the same problem but none of the solutions is applicable to my case.

I run Pi-hole in a docker container as my DNS server - for the server it is running on (Ubuntu 18.04), and the rest of my home network. It works fine, everything resolves as expected.

Except in one specific case: when Pi-hile itself is starting. It wants to check something on the Internet and fails because the DNS resolution obviously fails.

This is not the end of the world but this triggered my question: can I set up systemd-resolved so that it chooses a DNS server based on the requested domain?

The questions in my introductory note mention the ability to do a split DNS but my understanding is that the DNS can only be set on a per-NIC basis. In other words, for one interface there can be only one DNS (or several backup ones, what I mean is that there is no possibility of dynamically choosing the one to use).

Is this understanding correct?

in flag
Would it be feasible to have a custom entry for the domain in `/etc/hosts`? This would bypass the need for DNS for that one domain altogether, which may be alright so long as the target IP does not change
cn flag
WoJ
@matigo: the problem with this solution is that I would need to list all the FQDN of the services, and this would need to be maintained manually. At some point I was considering writing a script to populate `/etc/hosts` with this information but I would very much prefer something more seamless.
muru avatar
us flag
What happens if you write a custom `resolv.conf`, and mount that inside the Pi-Hole container at `/etc/resolv.conf`?
cn flag
WoJ
@muru: so that the name that fails during startup is forcefully resolved, you mean? Yes, that's an idea but the target IP can change. Still, it is a fix and I would check from time to time if this manual resolution is still fine. Thanks for the hint (I guess that my understanding of how dynamic/split DNS works is (unfortunately to me) correct, right?)
muru avatar
us flag
`resolv.conf` contains DNS configuration (like nameservers, search domains, etc.). So essentially you're just setting up a separate DNS configuration for Pi Hole, that's all - not hardcoding IPs for some domains - that's `/etc/hosts`.
cn flag
WoJ
@muru: ahhh, sorry, I read `/etc/hosts` instead of `/etc/resolv.conf` ! Ah yes, this is now a very good idea :) Thanks, I will try it right away!
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.