Zone File Directives

The four directives are evenly divided into two that simplify the construction of a zone file, $INCLUDE and $GENERATE; and two that define values used by the resource records, $ORIGIN and $TTL.

The $TTL Directive Defines the default TTL for resource records that do not specify an explicit time to live. The TTL value can be specified as a number of seconds, or as a combination of numbers and letters. Defining one week as the default TTL using seconds is

$TTL 604800

Using the alphanumeric format, one week can be defined as

$TTL 1w

The letter values that can be used with the alphanumeric format are

The $ORIGIN Directive Sets the current origin, which is the domain name used to complete any relative domain names. By default, $ORIGIN starts out assigned the domain name defined on the zone statement. Use the $ORIGIN directive to change the setting. For example, the following directive changes the origin to


Like all names in a zone file, the domain name on the $ORIGIN directive is relative to the current origin, unless it is fully qualified. Thus, if the zone statement defines the domain and the zone file contains the following $ORIGIN directive:

$ORIGIN ducks

The effect is the same as the previous $ORIGIN directive. The name ducks is relative to the current origin Therefore, the new origin is Relative names in any resource records in the zone file that follow this $ORIGIN directive are relative to this new origin.

The $INCLUDE Directive Reads in an external file, and includes it as part of the zone file. The external file is included in the zone file at the point where the $INCLUDE directive occurs. The $INCLUDE directive makes it possible to divide a large domain into several different files. This might be done so that several different administrators can work on various parts of a zone without having all of them try to work on one file at the same time. The directive begins with the $INCLUDE keyword, which is followed by the name of the file to be included. All filenames in the zone file are relative to the directory pointed to by the directory option in the named.conf file, unless fully qualified to the root.

The $GENERATE Directive The $GENERATE directive create a series of resource records. The resource records generated by the $GENERATE directive are almost identical, varying only by a numeric iterator. An example shows the structure of the $GENERATE directive:


The $GENERATE keyword is followed by the range of records to be created. In the example, the range is 1 through 4. The range is followed by the template of the resource records to be generated. In this case, the template is $ CNAME $.1to4. A $ sign in the template is replaced by the current iterator value. In the example, the value iterates from 1 to 4. This $GENERATE directive produces the following resource records:

1 CNAME 1.1to4

2 CNAME 2.1to4

3 CNAME 3.1to4

4 CNAME 4.1to4

Given that is the value defined for the current origin, these resource records are the same as CNAME CNAME CNAME CNAME

These odd-looking records have a very specific purpose for delegating reverse subdomains. Delegating reverse domains is covered later in this chapter. The purpose of these odd resource records is described there.

Now that you know what records and directives are available and what they look like, you're ready to put them together to create a database.

Was this article helpful?

0 0

Post a comment