DNS zone file generator for Bind name server. It keeps fully customizable forward and reverse zones synchronized and reloads the server when necessary.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
.gitignore
.metadata
BUGS
HACKING
LICENSE
README
bndc.d
cmds.d
eparser.d
gen.d
globals.d
hosts.d
ipaddr.d
kompiluj
scanzone.d
vars.d
zones.d

README

BNDC - DNS zone file generator
================================================================================

If you run your own Bind nameserver(s) and you need to keep your forward
and reverse zones synchronized, this tool is for you.

It's a WIP and English documentation is sparse, but the example directory should
contain working configuration. Basically it uses template files (.tpl
extension by default) as a source of zone data and it generates corresponding
zone files (.db extension by default).

What makes this tool different (i.e. why I wrote it) ?

- templates files try to closely resemble zone files, making migration easy. 
You can even put ordinary Bind records into a template and they will carry
into the generated zone file without change.

- reverse zones are generated from A records (not limited to a single forward
zone) and you can customize them with !PTR commands and PTR records and whatever
other records you wish. This is handy for IPs with multiple hostnames.

- you can use user defined variables to insert arbitrary data into your
zones.

IPv6 is not supported yet, but as mentioned above, you can put AAAA records
to the zone directly.

===============================================================================

Compiling
---------

Visit http://www.dlang.org for up to date D compiler. DMD is recommended for
latest Dlang features. Other D compilers are GDC (gcc backend) and LDC (LLVM
backend).

Run 'kompiluj' script to compile bndc (it's too simple, I know).

You can also use binary release, available on github, if you don't want to
mess with the D compiler.

Installing
----------

Copy bndc binary to /usr/local/bin or any other path of your choice.

Create directory for bndc data (you can use /etc/bind or similar). Create
config.tpl and your zone templates (see the example directory). BNDC uses
current directory for reading and writing its data by default, but it's
recommended to use separate directory for templates and for generated zones.

Using BNDC
----------

Have a look into the example directory. BNDC uses template files which are
basically ordinary zone files with special tokens. All tokens start with
exclamation mark '!' and there are two kinds of them: variables ( !var or
!var=value ) and commands ( !COMMAND(argument) ). Some variables are used by
BNDC, some are set by BNDC and all of them can be set and used by the user (in
any template file).

If you run bndc from the example directory, first it's going to read the
file config.tpl (you can change this with --config option).  It process the
file sequentially, first setting various variables and then executing
commands (!DOMAIN and !REVERSE).

Each domain requires it's own template. They are stored in the template
directory. There can also be a header and footer template which are included at
the top and bottom of each processed template.

Generated zone files are stored in the zone directory, together with index
(bndc-zones.conf by default) which you can $include into your named.conf.

After a zone file is generated, bndc executes shell command stored in
!cmd_checkzone variable. Similarly, at the end !cmd_checkconf command is
executed.

If there are no errors (0 return value), !cmd_reload is executed.

Configuration syntax
--------------------

!variable = value [!var=value]
!variable = "val ue"
!variable = `echo "hello"`
!variable = "value !var"
!variable = ""
 - whitespace outside quotes is ignored
 - new value overwrites previous value
 - nonexistent variable evaluates to empty string

!command(argument)
 - argument is specific to each command
 - repeated command means repeated call

config.tpl - default first template to read

BNDC sets following variables:
!host - last hostname from !A, !AAAA, !H commands
!zone - currently processed zone (domain)
!zonefile - generated zone file
!version - zone serial number (SOA)
!rrttl - resource record TTL, empty at the start of each zone.

for other variables used by BNDC, see example/default_config.tpl

Commands:
!TTL(1d)                 - $TTL 1d
!SOA(domain.cz)          - domain.cz SOA: !nsname !maintname (!version !refresh !retry !expire !negttl)
!NS(ns1.isp.net., ns2)   - NS records (beware trailing dot!)
!MX(10 mail.domain.cz.)  - MX records (beware trailing dot!)
!A(host, 10.20.30.40)    - A record
!AAAA(host6, aa:bb::01)  - AAAA record - NOT IMPLEMENTED
!H(some.host.com.)       - dummy host for !CNAME etc
!CNAME(myname)           - CNAME to previous host (uses !host variable)
!PTR(10, some.host.com.) - override PTR in internal database (PTR record is
                           generated as ordinary from the database). Intended
                           for reverse zone templates.
!DOMAIN(domain.cz)       - generate forward zone
!DOMAIN(domain.cz, also-notify {109.123.212.22;}) - forward zone with optional options
!REVERSE(10.20.30)       - generate reverse zone 30.20.10.in-addr.arpa
!REVERSE(10.20.0.0/16)   - generate reverse zone 20.10.in-addr.arpa

Contact
-------
Martin Krejcirik <mk@krej.cz>

License
--------
These sources are free, they are redistributable and modifiable
under the terms of the Boost Software License, Version 1.0.
The terms of this license are in the file LICENSE,
or see http://www.boost.org/LICENSE_1_0.txt.