The zone file generator

Stephane Bortzmeyer

$Date: 2003-10-22 16:19:18 $


It is quite difficult to write a software that will work for every NIC in the world (even with a lot of options in the configuration file). Unless everybody chooses the same model of a registry, of course. But if you want to follow your own way, you'll have to do some coding. One element of this software is the zone file generator, that will create a zone file from the information stored in the database.

In this model, the information (domain names, contacts, name servers - not always with the IP address, only when it's necessary, resellers, etc) is in some sort of database (a RDBMS, for instance) and the zone file is generated from the database.

To extract info from the database, use something like Perl DBI (a ten-line script is sufficient) or a shell command as simple as (for PostgreSQL):

#!/bin/sh
psql -q --no-align --tuples-only registry \
     -c "SELECT address, hosts.name as host, domains.name as domain\
           FROM Hosts,Domains,Nameservers\
           WHERE nameservers.domain = domains.id AND \
                 nameservers.nameserver = hosts.id" |\
   awk -F \| '{ print $3". IN NS "$2"."; if ($1) {print $2". IN A "$1"" } }' 

This generator is not perfect. If a name server is used for N domains, its glue record will appear N times in the zone file. But you get the idea.

This is more work than just managing the BIND zone file by hand but it's worth it.

Pour toute question concernant le NIC générique, vous pouvez nous écrire à info@generic-nic.net.

(sa dernière regénération par WML 2.0.11 (19-Aug-2006) date du Lundi 26 Octobre 2009)