2

I'm now using public DNS over VPN to avoid some DNS pollution in China. But this come with a price that I can't take advantage of CDN.

Is there a way to configure dnsmasq and let it query both DNS servers, both public one and ISP one, and return the IP with a lower metric?

I knew it could be done by using server=/domain/server directive to assign a DNS server for a certain domain, but the problem is there are hundreds of them. So I have to figure out something generic.

Thanks in advance.

xiaoyi
  • 123

3 Answers3

1

DNSmasq cannot do this for you. Powerdns with the pipe backend however can as you can write your own code to do the resolving. I would use python pydns for the backend as it can easily query arbitrary nameservers.

1

Is there a way to configure dnsmasq and let it query both DNS servers, both public one and ISP one, and return the IP with a lower metric?

dnsmasq provides the options --all-servers

--all-servers

By default, when dnsmasq has more than one upstream server available, it will send queries to just one server. Setting this flag forces dnsmasq to send all queries to all available servers. The reply from the server which answers first will be returned to the original requestor.

This options does answer your problematic

Spredzy
  • 963
0

I don't think dnsmasq gives you this ability. There is a solution that lies with bind though. I know they say setting up bind is an overkill but it's not too bad for what you are trying to do.

options {
    forwarders {
            x.x.x.x;        //ISP dns ip address
            y.y.y.y;        //Public dns ip address
    }
}

The key is that forwarders are queried in order from TOP to bottom. So the ISP will be queried first (which also gives a lower metric most probably) and if it fails, the Public one will be queried.

nass
  • 598