2

I want to use two different DNS providers, a.com and b.com.

I want a list of domains like google, youtube, superuser (and more) to be resolved with a.com.

And I want all other domains to be resolved with b.com.

How can I accomplish this?


Note: There are a lot of websites which I want them to be resolved with a.com so resolving them all through a script and use hosts file to point those domain to their addresses is not an option because the static IPs might change, and the list might change as well.


This question has been asked 3 times (at least) on superuser in different forms but have not been well-received. (No answer or no accepted/upvoted answer):

Can dnsmasq resolve specific domain by more than one server?

Selective DNS server usage

Using dnsmasq with network provided DNS server

1 Answer 1

2

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.

1
  • 1
    I have been banging my head against the wall past two days.. I just couldn't figure it out and I read a lot of questions and articles xD. I thank you very very much for this! :D
    – Shayan
    Commented Sep 1, 2019 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .