Wednesday, December 18, 2024
HomeUNIX softwareBIND and DNSDNS/BIND resource record: using $GENERATE to make many records

DNS/BIND resource record: using $GENERATE to make many records

A cool feature in versions of BIND since 8.2 and 9.1 is the $GENERATE directive which can create hundreds or thousands of resource records with a single line in zone file. A common use for $GENERATE is assigning PTR records for a DHCP address range.


Given the subnet 192.168.2.0/24 which is reserved (with the exception of reserved addresses 192.168.2.1-10) for use by a DHCP server pool, reverse lookup (PTR) records of the format dhcp#.tech-recipes.com. (where # is the address) can be created with the following line in the zone file:

$GENERATE 11-254 $ PTR dhcp$.tech-recipes.com.

This will generate the following records:

11 PTR dhcp11.tech-recipes.com.
12 PTR dhcp12.tech-recipes.com.
13 PTR dhcp13.tech-recipes.com.
...
253 PTR dhcp253.tech-recipes.com.
254 PTR dhcp254.tech-recipes.com.

This code works assuming that the zone file is associated with the 2.168.192.in-addr.arpa. domain. The $GENERATE is currently only compatible with the A, AAAA, CNAME, DNAME, NS and PTR resource record types.

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!