Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Example:

$TTL 120
$ORIGIN mywebsite.com

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

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

share|improve this question
1  
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
add comment

1 Answer

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       112.134.156.178
www  CNAME   mywebsite.com. ; Invalid, CNAME cannot share with an A record
www  A       111.122.133.144
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       192.0.2.200
     A       192.0.2.201

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.