## BIND Configuration Guide -- Master File Format

The Master File Format was initially defined in RFC 1035 and has subsequently been extended.

While the Master File Format is class independent all records in a Master File must be of the same class.

### Master File Directives

#### $ORIGIN

Syntax: `$ORIGIN <domain-name> [<comment>]`

`$ORIGIN` set the domain name that will be appended to any unqualified records. When a zone is first read in there is an implict `$ORIGIN` <zone-name>. The current `$ORIGIN` is appended to the domain specified in the `$ORIGIN` argument if it is not absolute.

    $ORIGIN EXAMPLE.
    $ORIGIN MYZONE
    WWW	CNAME	MAIN-SERVER

is equivlent to

    WWW.MYZONE.EXAMPLE. CNAME MAIN-SERVER.MYZONE.EXAMPLE.

#### $INCLUDE

Syntax: `$INCLUDE <filename> [<origin>] [<comment>]`

Read and process the file filename as if it was included into the file at this point. If origin is specified the file is processed with `$ORIGIN` set to that value otherwise the current `$ORIGIN` is used. NOTE: The behaviour when <origin> is specified differs from that described in RFC 1035.

The origin and current domain revert to the values they were prior to the `$INCLUDE` once the file has been read.

#### $TTL

Syntax: `$TTL <default-ttl> [<comment>]`

Set the default Time To Live (TTL) for subsequent records with undefined TTL's. Valid TTL's are of the range 0-2147483647.

`$TTL` is defined in RFC 2308.

### BIND Master File Extentions

#### $GENERATE

Syntax: `$GENERATE <range> <lhs> <type> <rhs> [<comment>]`

`$GENERATE` is used to create a series of resource records that only differ from each other by an iterator. `$GENERATE` can be used to easily generate the sets of records required to support sub /24 reverse delegations described in RFC 2317: Classless IN-ADDR.ARPA delegation.

    $ORIGIN 0.0.192.IN-ADDR.ARPA.
    $GENERATE 1-2 0 NS SERVER$.EXAMPLE.
    $GENERATE 1-127 $ CNAME $.0

is equivalent to

    0.0.0.192.IN-ADDR.ARPA NS SERVER1.EXAMPLE.
    0.0.0.192.IN-ADDR.ARPA NS SERVER2.EXAMPLE.
    1.0.0.192.IN-ADDR.ARPA CNAME 1.0.0.0.192.IN-ADDR.ARPA.
    2.0.0.192.IN-ADDR.ARPA CNAME 2.0.0.0.192.IN-ADDR.ARPA.
    ...
    127.0.0.192.IN-ADDR.ARPA CNAME 127.0.0.0.192.IN-ADDR.ARPA.

range
  This can be one of two forms: start-stop or start-stop/step. If the first form is used then step is set to 1. All of start, stop and step must be positive.
lhs
  Lhs describes the owner name of the resource records to be created. Any single $ symbols within the LHS side are replaced by the iterator value. To get a $ in the output use \$. If the lhs is not absolute the current $ORIGIN is appended to the name, when appropriate. You can also apply an offset to the iterator by using ${offset} where offset is a decimal value to add to the iterator. And you can also change the format of the iterator by using a printf like string. The format is ${offset,width,radix} where offset is as before (use 0 for no change), width is the minimum field width (always zero padded) radix is one of d, o, x, or X to change the radix to decimal, octal, hex, or hex with capital letters. The default is ${0,1,d}. For example: ${16,3} will add 16 to the iterator and be replaced by a 3 digit decimal representation. ${0,2,x} will be replaced by a 2 digit hex representation. To get a { character inserted into the text immediately after the iterator, use $\{.
type
  At present the only supported types are A, AAAA, PTR, CNAME and NS.
rhs
  Rhs is the data. It is processed similarly to the lhs.

## Resource Records

Syntax: `{<domain>|@|<blank>} [<ttl>] [<class>] <type> <rdata> [<comment>]`

All resource records have the same basic syntax.

`domain`
  Specify the domain name for this record. If it is not absolute the current `$ORIGIN` is appended.
`@`
  Use the current `$ORIGIN` for the domain name for this record.
`blank`
  Use the last specified domainname.
`ttl`
  This specifies how long this record will be cached by caching servers. The valid range is 0-2147483647.
`class`
  Specify the class of this record. This is usually redundent as the class of a zone is specfied in the configuration file prior to reading the zone file.
`type`
  Specify the type of this record. This describes the contents of the rdata section.
`rdata`
  This is the value of the resource record.

## Time Values: Alternate Specification format (BIND Enhancement)

Many time values within the MASTER file may be specified in multiples of weeks, days, hours, minutes and seconds rather than just seconds.

The format for this is `#w#d#h#m#s`. To specify 1 week you would use `1w` or two weeks and 1 hour `2w1h`.

This format applies to TTL values, and SOA REFRESH, RETRY, EXPIRE and MINIMUM values.