]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
new: usr: Add support for zone templates
authorEvan Hunt <each@isc.org>
Tue, 3 Jun 2025 19:45:06 +0000 (19:45 +0000)
committerEvan Hunt <each@isc.org>
Tue, 3 Jun 2025 19:45:06 +0000 (19:45 +0000)
To simplify the configuration of multiple similar zones, BIND now supports a zone template mechanism. `template` blocks containing zone options can be defined at the top level of the configuration file; they can then be referenced in `zone` statements. A zone referencing a template will use the options in the specified `template` block as defaults. (Options locally defined in the `zone` statement override the template.)

The filename for a zone can now be generated parametrically from a format specified in the `file` option. The first occurrences of `$name`, `$type` and `$view` in `file` are replaced with the zone origin, the zone type (i.e., primary, secondary, etc), and the view name, respectively.

Primary zones can now take an `initial-file` option, specifying the path to a generic zone file that will be copied into the zone's `file` path when the zone is first loaded, if the `file` does not already exist.

For example, the following template can be used for primary zones:
```
        template primary {
                type primary;
                file "$name.db";
                initial-file "generic.db";
        };
```

With this template in place, a new primary zone could be added using a single `rndc addzone` command:

```
        $ rndc addzone example.com '{ template primary; };'
```

The zone would be created using the filename `example.com.db`, which would be copied into place from `generic.db`.

Closes #2964

Merge branch '2964-zone-templates' into 'main'

See merge request isc-projects/bind9!10407


Trivial merge