This is just split-horizon DNS service at a proxy DNS server, which is fairly simple in the straightforward case.
- For a forwarding proxy DNS server one simply uses conditional forwarding. Consult your DNS server software's manual for how to do conditional forwarding. djbdns, Microsoft's DNS server, ISC's BIND, my DNSFCPD, and several others can all do conditional forwarding.
- For a resolving proxy DNS server one uses whatever delegation override mechanisms the server software supplies. For djbdns, one adds a file to the
servers/
directory. For ISC's BIND and Microsoft's DNS server, one uses stub zones.
The problem is that CDNs are not straightforward cases and you are preparing a perpetual maintenance headache for yourself.
Sometimes CDNs use rather lengthy alias chains. There's no way for you to know where in the chain the CDNs distribution information is encoded, because every CDN is free do to this in its own way.
For example: www.microsoft.com.
is an alias for toggle.www.ms.akadns.net.
which is an alias for g.www.ms.akadns.net.
which is an alias for lb1.www.ms.akadns.net.
which maps to the IP address 65.55.12.249
. You could do the prune-and-graft at microsoft.com.
, g.www.ms.akadns.net.
, www.ms.akadns.net.
, ms.akadns.net.
, or akadns.net.
. But you don't know which is the appropriate place without knowledge that is both specific to that one CDN and not even necessarily known to you in the first place. Get it wrong, and you're back with the problem of the back-end queries coming from a third party's IP address, and the DNS data being appropriate for that address not for yours.
Moreover, Akamai is free to change all of those intermediate domain names, ten minutes from now, without any requirement to inform you about it so that you can reconfigure your split-horizon overrides. And it's free to do it all over again tomorrow. Multiply that by all of the different CDNs that you intend to use split-horizon DNS service for, and you have a huge Red Queen's Race ahead of you.
In any case, as others have pointed out, it's not really a good idea to use third-party, contractless, external, advertiser-funded, promiscuous proxy DNS servers in the first place. People wouldn't dream of handing over to advertiser-funded, contractless, external third-parties for proxy HTTP service, or SMTP Submission service. Proxy DNS service is little different, and the same rationales apply. What you are wanting to do is actually a fairly bad idea.
If you want to make your LAN's DNS lookups perform better, work on that, instead.