The question is as follow: how can I set up a DNS proxy/cache that queries in a strict order a series of DNS servers (of which some might be unavailable), and that does not stop on the first NXDOMAIN answers.
Context:
The place I work for has a main domain: company.com, and 2 VPNs: vpn1 and vpn2. They are not identical: vpn2 allows you to connect to more services than vpn1. vpn1 is not needed when connected to vpn2 basically.
Some sub-domains are available from the internet: open.company.com
Some are only available from vpn1 and vpn2: internal.company.com
Some are only available from vpn2: private.company.com
Now, vpn1 has a DNS server: dns1 and vpn2 has a different DNS server: dns2; each with its own configuration.
The issue is: some services that are accessible from VPN1 (and therefore VPN2) are configured in dns1, but not in dns2.
And the bigger problem is that when dns2 is asked, it answers with NXDOMAIN.
So I'm looking for a way to ask the DNS in this specific order: dns2, dns1, 8.8.8.8, but without stopping on the first NXDOMAIN answer.
I tried with DNSMasq and the "all-servers" parameter, it has 2 issues:
- I think (I haven't tested) that if the NXDOMAIN from dns2 arrives before the answer from dns1, the query will fail
- Some sub domain are resolved by both dns1 and dns2, but when connected to vpn2, the IP configured in DNS2 should be used.
I've looked at dnsmasq, bind, and other random DNS proxies, but without any luck so far.
Note: obviously, I can't update the configuration of DNS1/DNS2. I'm looking for a solution that would run on my laptop (ubuntu)
Any idea?
Thanks