= Bind Zone Files = '''BIND zone files''' come in two categories: '''forward zones''' (located in `/var/named/primary/*`) and '''reverse zones''' (located in `/var/named/reverse/*`). Note that this format, standardized in [[https://tools.ietf.org/html/rfc1035|RFC 1035]], has been widely adopted outside of the BIND project. <> ---- == Forward Zone == To check the configuration of the forward zone file for `example.com`, run... {{{ named-checkzone -d example.com /var/named/primary/example.com }}} === Example === This is a forward zone file for `example.com`. {{{ $TTL 1D @ IN SOA host1.example.com. me.example.com. ( 10 ; Serial 8H ; Refresh 2H ; Retry 4W ; Expire 1D ) ; Minimum ; IN NS host1 IN MX 10 host1 ; example.com. IN A 192.168.1.1 host1 IN A 192.168.1.1 www IN CNAME host1 ftp IN CNAME host1 ; host2 IN A 192.168.1.201 host3 IN A 192.168.1.202 }}} === Structure === The first column is the '''fully qualified domain name''' ('''FQDN'''). If this column is omitted, the last-defined FQDN is implicitly referenced. The second and third columns are the record type. The second column is almost always '''Internet''' ('''IN'''). === Start of Authority === This line indicates that host1.example.com is the '''Start of Authority''' ('''SOA''') for the zone, and that `me@example.com` is the technical contact. `@` is a macro for the fully qualified domain name, defined in the `bind(8)` configuration. {{{ @ IN SOA host1.example.com. me.example.com. }}} Note the period is mandatory to indicate that they are FQDNs. === Name Server === This line indicates that the previously-defined FQDN is also the '''Name Server''' ('''NS''') for this zone. {{{ IN NS host1 }}} === Mail Exchange === This line indicates that the previously-defined FQDN is also hosting a mail server (or '''Mail Exchange''') ('''MX'''). It should be defined with a priority; here that is set to 10. {{{ IN MX 10 galaxy }}} There are additional considerations for public MX records; see [[Email/DNSRecords|here]] for details. === Address === To define the address for a domain name, use '''Address''' ('''A''') records. {{{ example.com. IN A 192.168.1.1 host1 IN A 192.168.1.1 }}} As with the SOA record, trailing periods are required to indicate a FQDN. After this line, `host1` can be referenced as an address. {{{ www IN CNAME host1 }}} ---- == Reverse Zone == To check the configuration of the reverse zone file for `192.168.1.0/24`, run... {{{ named-checkzone -d 1.168.192.in-addr.arpa /var/named/reverse/192.168.1 }}} === Example === This is a reverse zone file for `192.168.1.0/24`. {{{ $TTL 1D @ IN SOA host1.example.com. me.example.com. ( 10 ; Serial 8H ; Refresh 2H ; Retry 4W ; Expire 1D ) ; Minimum ; IN NS host1.example.com. 1 IN PTR host1.example.com. ; 201 IN PTR host2.example.com. ; IP address for 'host2' 202 IN PTR host3.example.com. ; IP address for 'host3' }}} ---- CategoryRicottone