How to make DNS Server return different answers based on network availability?

14 views Asked by At

I Have a Bind9 docker container acting as the DNS Server of my network, I want this behavior when bind9 is asked about example.com:

If (Network is available):
  ask from 8.8.8.8 about example.com
If (Network is not available):
   return 172.16.2.2 as example.com

In other words I want bind9 to forward dns queries for example.com to 8.8.8.8 and if network is not available I want it to fallback to my local zone.

So far I have created a zone in my named.conf like this:

zone "example.com" {
    type master;
    forward first;
    max-zone-ttl 1;
    forwarders {
     8.8.8.8;
   }; 
   file "/etc/bind/db.example.com";
};

But it always returns the Ip in the local zone file (172.16.2.2). Isn't bind9 supposed to forward my requests first and then fallback to local zone?

0

There are 0 answers