Search code examples
parsingdnsbindzonednsjava

Zone file format issue, dnsjava parser crashing - BIND 9


I am making an application that uses a parser to parse all the master zones from the DNS, the parser I am using is from dnsjava library (org.xbill.DNS.Master). All the zones I am parsing are already added into BIND 9 via rndc. The problem I am facing is that some of the zone files aren't parsing, the parser gives the error

@ is not an absolute name

An example is given below, the name of this zone is pensoul.my, it's file looks like,

@ 1800 SOA ns5.mydns.my. dnsadmin.mydns.my.  2015070201 3h 1h 1w 30m
@ 84600 NS ns5.mydns.my.
@ 84600 NS ns6.mydns.my.
@ 3600 A 202.190.174.39
www 3600 A 202.190.174.39

On parsing this, and all the zones that are of this format, I am getting the absolute name error.

To check the format of this zone file, I used the command,

named-checkzone pensoul.my *filepath*

and it gives a status of OK, which means there is nothing apparently wrong with the file format.

Do I need to use another parser, or is there a way around for this?


Solution

  • From what you say, it sounds like the parser either is faulty or at least gives you a misleading error message. @ denotes the current origin in the zone file. According to the RFC, the current origin can be set by an $ORIGIN directive, an $INCLUDE directive or by an argument to the routine loading the zone file. In your case, BIND will use the name of file as the "argument to the routine loading" case. It appears that your Java parser does not. This may be because you failed to call it properly, or because it's buggy and doesn't handle the external case. You'll have to look that up in your code and/or the library documentation.