I'm running an authoritative nameserver for a reverse /16 zone, where every IP is mapped to a custom subdomain.
This is achieved by a zone file with 256 $GENERATE
directives, for example (subnet 11.22.0.0/16):
$GENERATE 0-255 $.1 PTR $.1.22.11.rev.example.com.
$GENERATE 0-255 $.2 PTR $.2.22.11.rev.example.com.
(...)
This works fine, the only issue is that whenever we add a "meaningful" reverse record (4.3.22.11.in-addr.arpa. IN PTR www.example.com.
) it will result in a situation where there are 2 PTR records for the same IP address:
4.3.22.11.in-addr.arpa. IN PTR www.example.com.
4.3.22.11.in-addr.arpa. IN PTR 4.3.22.11.rev.example.com.
For the most part this is fine, but in some cases we need to have a single PTR record.
The solution has been to "unroll" the $GENERATE
block into individual PTR records and replace the offending one. Is there a way to override a generated record without having to expand the whole range?
This nameserver runs BIND 9.8.2 on RHEL6.
The
$GENERATE
Directive only has two forms for range: start-stop or start-stop/step. Because of this you can't exclude one IP from the range, but you have to split the range accordingly, e.g.There is no way to do this unfortunately. You're stuck with "unrolling".
In memory, the $GENERATE directive causes individual PTR records to be generated. This can be observed by viewing the zone file received by the secondary servers after zone transfer, which does not contain a $GENERATE directive. There is no syntax that allows you to selectively override the individual PTR records.
An alternative is mentioned in Chapter 8 of DNS for Rocket Scientists, which is to add a step of using
named-checkzone
to parse out the $GENERATE directive and replace it with individual PTR records:The downside is, naturally, the fact that your zone file on the master becomes much larger. At this point you're only using $GENERATE to build the initial reverse zone for you so that the individual PTR records don't have to be typed out by hand, and a shell script could have easily achieved the same end result there.
This probably isn't the solution that you were hoping for, but that's the state of things unfortunately. :(
Though you may not be able to make an exception within the zone that contains the
$GENERATE
, you can define a Response Policy Zone. A Response Policy Zone should let you override any response you wish.