Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank 'name' field in DNS zone file record

Tags:

bind

dns

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 example.com

@    NS      example.com
@    A       192.0.2.178
www  CNAME   example.com
     A       192.0.2.144
file CNAME   example.com

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

like image 813
Drew Avatar asked Dec 12 '11 05:12

Drew


2 Answers

A blank "name" field means just use the same name as the previous record, so in your example that A record is for www.example.com. See §5.1 of RFC 1035.

If an entry for an RR begins with a blank, then the RR is assumed to be owned by the last stated owner.

However that also makes this particular file illegal - you can't have a CNAME and an A record present at the same label. See §3.6.2 of RFC 1034.

like image 80
Alnitak Avatar answered Sep 29 '22 07:09

Alnitak


I know this is an old question - just stumbled accross it whilst look for something else, anyway the last comment - "A blank "name" field means just use the same name as the previous record" is NOT correct.

Any time a label is absent from a zone file (the label is the field on the left - i.e., the hostname or fully qualified domain name), it is qualified by the value of the $ORIGIN variable ($ORIGIN = example.com in this case - which can also be referenced by @).

So in the above zone file, the record...

A 192.0.2.144 is the same as
example.com A 192.0.2.144 as is..
@ A 192.0.2.144

Having said all that, this zone file contains quite poor syntax as none of it seems to be FULLY qualified - i.e. no trailing dot at the end for the root - as in

$ORIGIN example.com.
and
somehost.example.com. IN A 192.0.2.144

I'm guessing the nameserver either didn't work well or was buggy.

Basically/generally in BIND zone file at least, if not fully qualified by trailing dot the the value of the $ORIGIN var is appended to the label.

like image 24
Poita Avatar answered Sep 29 '22 06:09

Poita