Jul's page (Hungarian) : Jul's packages : djbdns-conf

The tinydns-genconf program

tinydns-genconf is a perl script which generates simple configuration files from /etc/hosts-style files, which can be converted to data.cdb with the tinydns-rebuild script.

Interface

     tinydns-genconf [directory]

where directory is a djbdns service directory (eg. it has env/ and root/ directories). If it is omitted, current directory is used.

It reads *.hosts hosts files from root/hosts/ directory, and writes *.conf data files to root/generated/ directory. It creates root/generated/ if it doesn't exists.

Hosts file format by example

The file format is very similar to /etc/hosts. It is a whitespace-delimited list of A/PTR and CNAME records. Eg. in file root/hosts/hq.lamer.com.hosts:

     #IP-address   name        [alias      [alias [...]]
     10.0.0.1      master      dns-server  dns-server.intranet
     10.0.0.1      www         web
     10.0.0.2      www.devel   www-devel
     10.0.0.3      free-nfs

The first line creates an SOA record to hq.lamer.com, to 0.0.10.in-addr.arpa, an A and a PTR record to master.hq.lamer.com, a CNAME record to dns-server.hq.lamer.com pointing to master.hq.lamer.com, an SOA record to intranet top-level domain, and a CNAME record to dns-server.intranet pointing to master.hq.lamer.com.

The second line creates an A record to www.hq.lamer.com and a CNAME record to web.hq.lamer.com pointing to www.hq.lamer.com.

The third line creates an A and a PTR record to www.devel.hq.lamer.com and a CNAME to www-devel.hq.lamer.com pointing to www.devel.hq.lamer.com.

The fourth line is not handled, because the second column starts with 'free.'

Thus, the rules:

  • Empty lines and strings starts with hash mark (#) are handled as comments.
  • Columns are separated by white space.
  • First column is mandatory: it contains the IP address.
  • Ssecond column is mandatory, and it contains the host name. If it contains a colon, it is handled as a simple subdomain (no SOA is generated). If host name starts with 'free' keyword, the whole line is skipped.
  • Third and other columns are optionally and they contain alias names. If an alias name contains a dot, it is handled as an FQDN (no domain name is added).
  • IP addresses and domain names are cached to make exactly one PTR and SOA record respectively. SOA records are generated to every C-class IP address space.
  • Every name and IP address is checked to contain lowercase letters and only standard elements ([a-z0-9.-]+ for host names, [0...255].[0...255].[0...255].[1...254] for IP addresses.) No unicode support is added.