Configure dnsmasq to selectively resolve domains using two DNS providers
The other answers you refer to seem to be doing something more complex than you're requesting. If I understand correctly a simple bit of dnsmasq config like:
server=/google.com/a.a.a.a#aaaa
server=/youtube.com/a.a.a.a#aaaa
server=/exception.youtube.com/#
server=/superuser.com/a.a.a.a#aaaa
server=b.b.b.b#bbbb
[...]
where a.a.a.a
is a.com's DNS server, and aaaa
is its port, (and so on for b.com), should do this.
http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html states,
More specific domains take precedence over less specific domains, so:
--server=/google.com/1.2.3.4 --server=/www.google.com/2.3.4.5
will send queries for *.google.com to 1.2.3.4, except *www.google.com, which will go to 2.3.4.5. The special server address '#' means, "use the standard servers"
Yes, the list could get quite long, but you can match multiple domains with one server line (and obviously don't need to resolve to IPs). You'll presumably be generating the file automatically, and inserting server lines as appropriate.