Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
    
powerdns looks great, but not very router friendly indeed. –  xiaoyi Nov 28 '12 at 18:52

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.

share|improve this answer
    
Thanks for your replying. But this will always get me polluted IPs. Seems I have to implement it myself... –  xiaoyi Nov 28 '12 at 12:08
    
@xiaoyi this will always get me polluted IPs why is that? Do the ISP dns server actually return a fake address instead of returning nothing? –  nass Nov 28 '12 at 12:12
    
yes, that's how ISP in China do it. like resolve google.com to some black hole IP. –  xiaoyi Nov 28 '12 at 12:13

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.