Linux – BIND v9.9.7, Views and includes

binddomain-name-systemlinux

I have recently begun upgrading to bind 9.9.7 and have run into an unfortunate stumbling block with bind.

I setup views in my environment to allow me to differentiate 4 of my zones with different IP addresses based on where the host is running a query from. The other 36 zones I serve do not differentiate IP addresses, but rather should always serve out the same address for each host. To accomplish this, I created a separate list of hosts which then I used an include directive in the named.conf to include those entries in both zones. Here's a short example of the configuration I have been running with on one of my slave servers:

First, a snippet of my named.conf

view "sitea" {
   match-clients {192.168.1.0/24;};
   zone "mydomain.com." IN {
      type slave;
      masters { 192.168.1.100;};
      file "sitea_mydomain.com.db";
   };
   include "/etc/common_zones.conf";
};

view "siteb" {
   match-clients {any; };
   zone "mydomain.com." IN {
      type slave;
      masters {192.168.1.100; };
      file "mydomain.com.db";
   };
   include "/etc/common_zones.conf";
};

And a snippet from the common_zones.conf file:

zone "1.168.192.in-addr.arpa." IN {
   type slave;
   masters {192.168.1.100;};
   file "192.168.1.db";
};

In the time before, bind was perfectly cool with using the same file twice within the view construct, but now it is not. Having a zone file listed twice in two different views causes an error that specifically tells you that bind will not allow this configuration. In this case it tells me it will not start because I have used a duplicate file 192.168.1.db. Specifically the error message is:

writeable file '192.168.1.db': already in use: /etc/common_zones.conf

The problem I have with this is in my real world, I have over 40 zones (reverse zones) that despite the view they come from, they will always be the same answer no matter what. Being able to use a general include as shown above was a wonderful way to allow me to differentiate a few hosts for the domain "mydomain.com". Now, I am faced with possibly needing to have to enter in 40 zones in each view, each pointing to a different file despite the fact that the data is identical.

Does anyone have a clever solution for this?

Best Answer

If upgrading to Bind 9.10 is a possibility, the "in-view" statement would solve this perfectly ( http://www.zytrax.com/books/dns/ch7/zone.html#in-view ).

However, if that's not possible, I noticed something quite interesting that I did not know while looking up "in-view". For slave zones, the "file" parameter (it happens to immediately precede "in-view" in the above link) is optional. This might be just the solution you're looking for. I'm assuming the zone would exist only in RAM and get retransferred every time the slave restarted or reloaded the zone. It's worth a shot. (Edit: You'd still need 2 versions of your common file, one for masters with file names, and one without - so this isn't quite a perfect solution)

Related Topic