Howto forward DNS request for local zone to external DNS when not matched locally (BIND9)
Use a response-policy
zone instead of a master zone for example.com
When attempting to resolve a hostname, bind will look in the response-policy
zone file first and if it does not find the answer it will continue looking.
Here's an example setup:
options {
# Your normal options
response-policy { zone "local_example_com"; };
};
zone "local_example_com" {
type master;
file "master/local_example.zone";
allow-query {none;};
};
Then add a zone file called master/local_example.zone
containing the following:
$TTL 24H
@ SOA LOCALHOST. named-mgr.example.com (1 1d 1h 30d 2h)
NS LOCALHOST.
host1.example.com A 192.168.1.1
host2.example.com A 192.168.1.2
host3.example.com A 192.168.1.3
host4.example.com A 192.168.1.4
When you try to resolve host1.example.com
it will get the answer from the response-policy
zone and when you try to resolve mail.example.com
it will resolve it using example.com
nameservers.