Take the 2-minute tour ×

I am currently parsing a large number of zone files at my work so that we can store this data in a database and easily regenerate zone files.

I am trying to make my parser quite strict, so that we can pick up any badly formed zone files and I'm coming across some records with nothing in the 'name' field.


$TTL 120
$ORIGIN mywebsite.com

@    NS      mynameserver.com
@    A
www  CNAME   mywebsite.com
file CNAME   mywebsite.com

How would that second A record be handled? And is it a valid syntax?

share|improve this question
Cut out the middleman and just wire your content DNS server up to the database directly. There are several content DNS server softwares that can be wired to various forms of back-end database. –  JdeBP Dec 23 '11 at 21:51

1 Answer 1

up vote 2 down vote accepted

Its name is a duplicate of the previous record, so in your example, it would be a 'www' Address record. In your example, the second '@ A' record does not need the '@'.

Your example with a CNAME is invalid, as a CNAME cannot have another record with the same name. As I recall, older versions of BIND only warned about this, but newer ones won't load a zone with these errors. Other types of records are valid - that's how you add multiple addresses for names (client-based DNS round-robin), or multiple (primary, secondary, and tertiary) MX or NS records for domains, for example.

$TTL 120
$ORIGIN mywebsite.com.

@    NS      mynameserver.com.
@    A
www  CNAME   mywebsite.com. ; Invalid, CNAME cannot share with an A record
www  A
file CNAME   mywebsite.com. ; Alias of www.mywebsite.com. 

What you should see in zones is similar to this:

$TTL 86400
$ORIGIN example.com.

; nameservers in another domain - must point at A records
@    NS      ns1.example.net.
     NS      ns2.example.net.

     ; mail hosted elsewhere - must be A records
     MX 10   mail.example.net.
     MX 20   backupmail.example.net.

; web farm - nameserver will return both A 
;  records when requested and client will alternate between them
www  A

; points at www.example.com. - in this case both CNAME (www.example.com.
;  and A records (, should be in the response returned.
www2 CNAME   www
share|improve this answer

Your Answer


