Information about starting and operating an ISP or corporate Intranet using Linux servers.


Stapler is a Perl application developed to simplify server DNS zone file maintenance.


Every time I added a server to my network, I had to change the zone files for all of the domains in which that server would be used. If it was a web or e-mail server, I might have a dozen zone files to edit. If I changed IP addressing schemes, I had to edit all the zone files. And half the time or more I would forget to change the serial number in one or more zone files. What a pain.

Stapler makes this all very easy by keeping your primary and secondary domains, machines, aliases (subdomains) and configuration in simple ASCII text files. You can add a new web server and have the zone files for a hundred domains re-written in seconds. Add a new subdomain for a customer and Stapler will re-write the zone files and refresh BIND's cache in the blink of an eye.

Recent updates

February 2017: Stapler 4.28 now supports single dynamic IP addresses, such as on a residential Internet service, that can be updated using a Cron job on the dynamic host and a simple web page on the DNS server that has Stapler on it. Running the Cron job every four hours, for example, would check your server's IP address every four hours and reload the DNS server if any IP addresses have changed.

:!: March 2017: Stapler 4.29 significant update with revision of several areas of logic. Now supports DKIM and TXT records. Forwarders support completed (was in config file but not implemented). Domains may have multiple records in domain.primary, e.g., a domain could have alternate servers, TXT, DKIM, and SPF record lines, whereas previously it could only be listed once.

Stapler 4.30 is anticipated this summer, which will have better error-checking of the configuration files and some minor bug fixes and cosmetic improvements in the zone file outputs.


To use Stapler you need to be using BIND for DNS resolution (it does not work with things like TinyDNS).

Stapler was initially developed in Perl 5 version 8 and is currently being used in Perl 5 version 22, so I expect that any version of Perl 5 will work properly, although I am only testing on the current Gentoo release at any given time.

Perl CPAN modules required:

  • Term::ANSIColor
  • Switch

As of April 2017 the Gentoo emerge command to install or verify installation of these modules is:

emerge -va perl-Term-ANSIColor dev-perl/Switch


Download the script and sample configuration files. The latest version is here:


Paths are preserved in the tar file. The Perl script should placed in /usr/local/bin/ and the configuration files in /etc/stapler/.

To view the archive you can use:

tar -tzf stapler-latest.tgz

To install the file as root do this:

tar -C / -xPpzf stapler-latest.tgz

Configure a weekly Cron job to update your DNS root server cache. In your root Crontab put something like this:

00  00  *  *  Sun wget -O /var/bind/root.cache


You will find comments within the configuration files, which include:

  1. 192.168.1 — a sample of a netblock configuration, you can have as many of these as you like.
  2. aliases.stapler — machine aliases (a.k.a., sub-domains).
  3. domain.primary — domains for which this DNS server is authoritative (i.e., the master).
  4. domain.secondary — domains names for which this DNS server is a relay (i.e., a slave).
  5. named.root — a copy of the root name servers that is publicly available.
  6. stapler.conf — the main configuration file.


You could leave a comment if you were logged in.