paulgorman.org/technical

Bind Zone Files

March 2021

$ORIGIN org.
$TTL 5m
;
example       IN    SOA    ns1.example.org. hostmaster.example.org. (
                           20210326  ; serial
                           4h        ; refresh - wait between refresh attempts by secondary
                           15h       ; retry - retry failed zone refresh by secondary
                           8h        ; expire - expiration of secondary authority
                           4m        ; negative result TTL
)
;
              IN    NS     ns1.example.org.
              IN    NS     ns2.example.org.
              MX    10     mail1.example.org.
              MX    20     mail2.example.org.
;
              IN    TXT    "v=spf1 a mx a:mail1.example.org a:mail2.example.org -all"
              IN    NAPTR  10  100  "s"   "SIP+D2U"  ""  _sip._udp.example.org.
_sip._udp     IN    SRV    10  100  5060  p1.example.org.
_sip._udp     IN    SRV    20  100  5060  p2.example.org.
;
ns1           IN    A      203.0.113.110
ns2           IN    A      198.51.100.33
mail1         IN    A      192.0.2.36
mail1         IN    AAAA   2001:DB8::6
mail2         IN    A      203.0.113.42
www           IN    CNAME  example.org.
p1            IN    A      203.0.113.27
p2            IN    A      198.51.100.154

A fully-terminated hostname has a dot on the end, like foo.example.com.. The $ORIGIN org. directive tells bind to append org. to any hostnames that appear after the directive that are not fully terminated. An $ORIGIN directive can be used more than once in a Bind config file, and affects all hostnames that appear after it (until the next $ORIGIN directive).

The $TTL 5m directive sets the default time to live for records in the zone. This is the time after which clients should ask again for a potentially updated record. Like $ORIGIN, the $TTL directive can be specified more than once in the same file.

The start of authority (SOA) record:

example       IN    SOA    ns1.example.org. hostmaster.example.org. ( …

example is the hostname. We could have written this as example.org., but the $ORIGIN directive will terminate the name with the TLD for us.

IN specifies the record type as “Internet”. Other record types are rarely used.