How to Solve Error Message zone zone_name IN: has no NS records

Posted on

Introduction

The error message as in the title above is the main issue of this article. There is an error appear when performing a command for checking the zone file configuration. A zone file configuration is part of DNS server configuration. The zone file can be a forward zone file and a reverse zone file. This article has a connection for further reference in another article with the title of ‘How to Install DNS Service in Linux Ubuntu 18.04’ in this link. Please look at the article for further information. In the case of the error above, it happens on checking the syntax of a forward zone file. Below is the command execution for checking a zone file where the execution is done in Linux Ubuntu 18.04 :

root@hostname# named-checkzone localhost.net.zone /var/cache/bind/localhost.net.zone 
zone localhost.net.zone/IN: has no NS records
zone localhost.net.zone/IN: not loaded due to errors.
root@hostname# 

The check process is using the command ‘named-checkzone’ as appear in the above output. The command for checking the syntax is done against a file with the name of ‘localhost.net.zone’. It is a forward zone file where it exist in ‘/var/cache/bind’. That folder is a specific folder to put zone file configuration which is important for the DNS service. The error is clear looking at the above output. There is no record of NS in that file. Below is the content of the file :

$TTL    86400
@       IN      SOA     ns1.localhost.net. root.localhost.net. (
        2018050600      ; serial
        3600            ; refresh after 2 hours
        3600            ; retry after 1 hour
        604800          ; expire after 1 week
        86400 )         ; minimum TTL of 1 day
;
; Define A records (forward lookups)
; @     IN      NS      ns1.localhost.net.      
ns1  IN A  127.0.0.1
app  IN A  127.0.0.1
db   IN A  127.0.0.1
test IN A  127.0.0.1

Solving the Problem

As in the above lines exist in the forward zone file configuration, there are only A record lines and there is no single NS record. line available. The A record is to define the mapping domain to its associate IP Address. But for the NS record, it is a specific record which has a sole purpose to define the name server. So, in order to be able to solve the error message above, just add an NS record. Below is the example of an NS record where it is pointing a local NS or pointing to a local DNS server :

;
; Primary nameserver
        IN      NS      ns1.localhost.net.

Put the above snippet code into the forward zone file. Overall, the content of that file will be available as follow :

$TTL    86400
@       IN      SOA     ns1.localhost.net. root.localhost.net. (
        2018050600      ; serial
        3600            ; refresh after 2 hours
        3600            ; retry after 1 hour
        604800          ; expire after 1 week
        86400 )         ; minimum TTL of 1 day
;
; Primary nameserver
        IN      NS      ns1.localhost.net.
;
; Define A records (forward lookups)
; @     IN      NS      ns1.localhost.net.      
ns1  IN A  127.0.0.1
app  IN A  127.0.0.1
db   IN A  127.0.0.1
test IN A  127.0.0.1

Try to execute the command for checking zone file once more, if there are no further errors, the following output will appear :

root@hostname# named-checkzone localhost.net.zone /var/cache/bind/localhost.net.zone 
zone localhost.net.zone/IN: loaded serial 2018050600
OK
root@hostname# 

Each mahine will have different output depends on the configuration file of the forward zone available in the machine.

Leave a Reply