Using a Single Data File for Multiple Zones

2.13.1 Problem

You want to use a single data file for multiple zones.

2.13.2 Solution

Create a "template" zone data file. Make sure that all of the owner names of records in the zone are "@" (short for the origin) or relative; that is, written without a trailing dot. For example:

@ IN SOA (
 3600 )




www IN CNAME @

Add zone statements to your name server's named.conf file, configuring it as primary master for the various zones, and specifying the "template" zone data file in the file substatement each time. For example:

zone "foo.example" {
 type master;
 file "db.template";

zone "bar.example" {
 type master;
 file "db.template";

zone "baz.example" {
 type master;
 file "db.template";

Since each zone statement sets the default origin to the domain name of the zone in the data file, the SOA record and NS records will always end up attached to the right domain name, and the rest of the records will end up "translated" into the zone.

2.13.3 Discussion

This technique will only work if all of the zones are very similar -- nearly identical, in fact. The zones must contain the same number and mix of records, and the records in the zones can only differ by the domain name of the zone. For example, if the domain name is an alias for in the foo.example zone, then will be an alias for the bar.example zone.

The name server must be the primary master for all of the zones; there's no way to set up an equivalent slave name server that uses the same backup zone data file for all of its zones, since name servers write fully qualified domain names to backup zone data files.

Also, none of the zones can be dynamically updated, since dynamic updates to a zone would cause the name server to rewrite the zone data file, and the rewritten zone data file would also contain fully qualified domain names.

2.13.4 See Also

Section 2.2 for understanding the default origin of a zone data file.

Getting Started

Zone Data

BIND Name Server Configuration

Electronic Mail

BIND Name Server Operations

Delegation and Registration


Interoperability and Upgrading

Resolvers and Programming

Logging and Troubleshooting


DNS & BIND Cookbook
DNS & BIND Cookbook
ISBN: 0596004109
EAN: 2147483647
Year: 2005
Pages: 220
Authors: Cricket Liu © 2008-2020.
If you may any questions please contact us: