Centos – Why can’t the DNS server start (bad zone error)

centosdomain-name-system

This is my config (running named on centos).

/etc/named.conf

options {
    ## path to zone files ##
    directory "/var/named";

    ## forward non-local to google ##
    forwarders { 8.8.8.8; };
};

zone "gallactica.lab" IN {
    type master;
    file "named.gallactica.lab";
    allow-update { none; };
};

zone "1.168.192.in-addr.arpa" IN {
    type master;
    file "rz-192-168-1";
    allow-update { none; };
};

/var/named/named.gallactica.lab

$TTL 1D
@       IN SOA  ns1.gallactica.lab. admin.gallactica.lab. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
IN NS      ns1.gallactica.lab.
IN A       192.168.1.105
ns1         IN A        192.168.1.105
proxmox     IN A        192.168.1.180

/var/named/rz-192-168-1

$TTL 1D
@       IN SOA  ns1.gallactica.lab. admin.gallactica.lab. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
IN NS      ns1.gallactica.lab.
105     IN PTR  ns1.gallactica.lab.
180     IN PTR  proxmox.gallactica.lab.

My DNS server is ns1.gallactica.lab at the address 192.168.1.105.


The error I'm getting when trying to restart the named service is:

Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone 1.168.192.in-addr.arpa/IN: not loaded due to errors.
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: _default/1.168.192.in-addr.arpa/IN: bad zone
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone localhost.localdomain/IN: loaded serial 0
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone localhost/IN: loaded serial 0
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0....ial 0
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
Jan 19 20:18:10 ns1.gallactica.lab named-checkconf[6469]: zone 0.in-addr.arpa/IN: loaded serial 0
Jan 19 20:18:10 ns1.gallactica.lab systemd[1]: named.service: control process exited, code=exited status=1
Jan 19 20:18:10 ns1.gallactica.lab systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
Jan 19 20:18:10 ns1.gallactica.lab systemd[1]: Unit named.service entered failed state.

Best Answer

Assuming you've kept the whitespace of the zone files intact when reformatting them in your question, it appears that you have no NS record at the top of the zone due to a formatting problem, which makes the zone bogus. You'll also want to correct the corresponding A record for that nameserver.

  • What you typed: IN NS ns1.gallactica.lab.
  • What you intended it to be interpreted as: 1.168.192.in-addr.arpa. IN NS ns1.gallactica.lab.
  • How it was actually interpreted: IN.1.168.192.in-addr.arpa. IN NS ns1.gallactica.lab.

When a line begins as whitespace, it's assumed that the label (name of the record) is the same as the previous record in the zone. This makes for useful shorthand, but creates portability problems when the leading whitespace is lost between copy and pastes.

As a side-note, it's useful to run named-checkzone when encountering problems such as this. (and following any zonefile modification, really)