$GENERATE directive to autocreate DNS records

isc bind$GENERATE directive is available in multi platform DNS server BIND since 8.2 version. It helps you to create hundreds or thousands of resource records with one line in zone file.

Nice example is to use $GENERATE in order to make PTR records for certain DNS zone.

Let’s assume that subnet is reserved for use by a DHCP server pool, in this case reverse lookup (PTR) records should like dhcp-#.yourdomain.com. (where # is the number from 1 to 254) can be created with the following lines in the zone file:

1 IN PTR dhcp-1.yourdomain.com.
2 IN PTR dhcp-2.yourdomain.com.
253 IN PTR dhcp-253.yourdomain.com.
254 IN PTR dhcp-254.yourdomain.com.

or with with single line:

$GENERATE 1-254 $ PTR dhcp-$.yourdomain.com.

Wide explanation of this directive you can find here.

P.S. From Wikipedia for newbies:

A PTR record or pointer record maps an IPv4 address to the canonical name for that host. Setting up a PTR record for a hostname in the in-addr.arpa. domain that corresponds to an IP address implements reverse DNS lookup for that address. For example (at the time of writing), www.icann.net has the IP address, but a PTR record maps to its canonical name, referrals.icann.org.


Stefan Durand

My name is Stefan, I'm the admin of LinuxScrew. I am a full-time Linux/Unix sysadmin, a hobby Python programmer, and a part-time blogger. I post useful guides, tips, and tutorials on common Linux and Programming issues. Feel free to reach out in the comment section.

1 thought on “$GENERATE directive to autocreate DNS records”

Leave a Reply

Your email address will not be published. Required fields are marked *