Blank 'name' field in DNS zone file record

1

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?

Drew

Posted 2011-12-12T04:50:25.497

Reputation: 115

1Cut 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 – 2011-12-23T21:51:04.300

Answers

3

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

Jamie Furtner

Posted 2011-12-12T04:50:25.497

Reputation: 46