0

I'm attempting to read the Verisign COM master zone file using the Master parser in DNSJava.

Here is an example input:

; The use of the Data contained in Verisign Inc.'s aggregated
; .com, and .net top-level domain zone files (including the checksum
; files) is subject to the restrictions described in the access Agreement
; with Verisign Inc.

$ORIGIN COM.
$TTL 900
@ IN    SOA     a.gtld-servers.net. nstld.verisign-grs.com. (
                  1539446539 ;serial
                  1800 ;refresh every 30 min
                  900 ;retry every 15 min
                  604800 ;expire after a week
                  86400 ;minimum of a day
                  )
$TTL 172800
 NS A.GTLD-SERVERS.NET.
 NS G.GTLD-SERVERS.NET.
 NS H.GTLD-SERVERS.NET.
 NS C.GTLD-SERVERS.NET.
 NS I.GTLD-SERVERS.NET.
 NS B.GTLD-SERVERS.NET.
 NS D.GTLD-SERVERS.NET.
 NS L.GTLD-SERVERS.NET.
 NS F.GTLD-SERVERS.NET.
 NS J.GTLD-SERVERS.NET.
 NS K.GTLD-SERVERS.NET.
 NS E.GTLD-SERVERS.NET.
 NS M.GTLD-SERVERS.NET.
COM. 86400 DNSKEY 257 3 8 AQPDzldNmMvZFX4NcNJ0uEnKDg7tmv/F3MyQR0lpBmVcNcsIszxNFxsBfKNW9JYCYqpik8366LE7VbIcNRzfp2h9OO8HRl+H+E08zauK8k7evWEmu/6od+2boggPoiEfGNyvNPaSI7FOIroDsnw/taggzHRX1Z7SOiOiPWPNIwSUyWOZ79VmcQ1GLkC6NlYvG3HwYmynQv6oFwGv/KELSw7ZSdrbTQ0HXvZbqMUI7BaMskmvgm1G7oKZ1YiF7O9ioVNc0+7ASbqmZN7Z98EGU/Qh2K/BgUe8Hs0XVcdPKrtyYnoQHd2ynKPcMMlTEih2/2HDHjRPJ2aywIpKNnv4oPo/
COM. 86400 DNSKEY 256 3 8 AQPepKpvbFtHVsAVm8kq+659WxFYXre5ngCIL53NuAMPybKPNEqgzF4+7GJExZB9LIDTH3ZK4QYAm7R14wEf9qGAjOpyIGF2jXqMkQ2G272hbEkFw6q5fawQByh3K7rXY8SAf2abpiXXh+Ms6LsvMarOpc7SwEt7Dbp1nvqgCA9jHw==
COM. 86400 DNSKEY 256 3 8 AQPeabgR6Fgrk5FSLilDYUedwsHA0HH22e8+Zp/uvp4aj1dVDAy5C9bkRA+xot3sG1KaT5hvgoE7eNV93F7pBW9rvVE3A/BNvJbLXxKhkAJV5KMFC10NRcdb+xF+sM4XTMPESPrYwTLUEpSFntMIVLAtUzLaBo6YpTVR20osgGgc3Q==
COM. 86400 NSEC3PARAM 1 0 0 -
COM. 86400 RRSIG NSEC3PARAM 8 1 86400 20181019044209 20181012033209 46475 COM. l0FoGsy2lG+9tlm2AA2wPNDAJV2PwhTVjUbSqGMcJqWc8ZTXlnUkaWnje4ws7KmAJIyQe3dMQ/RnZoF0CQluNilPWWVNm/Zz01r+M96V288H36UiiP0aPX9OcPaSCxRumuZmeiHNOWmMm+fbwNtPSJa3IkxKXMM1dT0qJ24n5v8=
COM. RRSIG NS 8 1 172800 20181019044209 20181012033209 46475 COM. LPV6Rjixhji/PQonHzKlnPxen/R/mZugUaj+fSpSQzQ7o4YLzZZ0k0J8linUu+RvdeI3p7+mdnUp5OergS7LAIsE2cQcvTpggJsi8aZk6r7QeqlvcYIEZfQ9vNpUVmZ/649SXvQppSq/RBbM4e0a1QQlUzXKiEUU53VDq2CUcnk=
COM. 900 RRSIG SOA 8 1 900 20181020160219 20181013145219 46475 COM. dbMGDD6f+2EEZMigc6FbzUj8Ou05s5iUmg7fhrKRu4vRUhZoG1MNqJ8Jy1LtyUTRswtp2xhY+n7g7zBxNBlpgOnseovEjmuEUz34P6h40jkSKvk75iSVKc9tFLciZi0svVQFL7B3eVKRR/zGsY6z4qX9cPWJHh5wwLYO3JgsQls=
COM. 86400 RRSIG DNSKEY 8 1 86400 20181019182533 20181004182033 30909 COM. vnSL1FfsX1/3qQw8ee20JqOAa9UNEvNjgCEmMu6HHfgQTKFy15DLMOA5VIWja6fbtASkc8YHJ5PWowWpWGiX9gE0g5i3TlMpiu6H3MQBjMgJWhtivzruEo4k2OknKRpfV18+rVf0MB55OAbqGS/J838PUFiYs7Rt7W7gYdFNRhWzS6VbdHElub0ySy4ZJTAt0muG7MphffC/Fgh9drgL0mpjfD2HynBbCKtgXOXJ6fHT6erkN2hMxu0AkJVwReNsQagOddtsK7RPPo1hfe5oZYBigVWtE/rvj6zHrRNKbyIcz+4fXpGmgayB2TACWc8vvRqcB3+VDaGxzIV4hGBo7Q==
KITCHENEROKTOBERFEST NS NS1.UNIREGISTRYMARKET.LINK.
KITCHENEROKTOBERFEST NS NS2.UNIREGISTRYMARKET.LINK.
KITCHENFLOORTILE NS NS1.UNIREGISTRYMARKET.LINK.
KITCHENFLOORTILE NS NS2.UNIREGISTRYMARKET.LINK.
KITCHENTABLESET NS NS1.UNIREGISTRYMARKET.LINK.
KITCHENTABLESET NS NS2.UNIREGISTRYMARKET.LINK.
KITEPICTURES NS NS1.UNIREGISTRYMARKET.LINK.
KITEPICTURES NS NS2.UNIREGISTRYMARKET.LINK.

I am able to parse other zone files that come from ICANN's CZDS program but Verisign's file throws this exception:

Caused by: org.xbill.DNS.Tokenizer$TokenizerException: :2: expected a string at org.xbill.DNS.Tokenizer.exception(Tokenizer.java:710) at org.xbill.DNS.Tokenizer.getString(Tokenizer.java:374) at org.xbill.DNS.Master.parseTTLClassAndType(Master.java:134) at org.xbill.DNS.Master._nextRecord(Master.java:364) at org.xbill.DNS.Master.nextRecord(Master.java:388) ... 28 more

1
  • Try to find which line makes the parser die, it is not very clear from the stacktrace. It is maybe because of the second $TTL keyword, while rare still allowed, and the first NS record after it that does not specify its owner (hence inheriting the last one but that is before the $TTL fragment) Commented Feb 24, 2019 at 17:29

1 Answer 1

2

I can parse your file fragment using this code and dnsjava 2.1.8:

import org.xbill.DNS.Master;
import org.xbill.DNS.Name;

public class parse {
    public static void main(String[] args) throws Exception {
        var master = new Master(args[0], Name.root, 86400);
        while (true) {
            var rr = master.nextRecord();
            if (rr == null)
                break;
            System.out.println(rr);
        }
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

That is interesting. I only used the constructor that takes an input stream. It may be possible that I will be parsing many different zone files and I won't know ahead of time the TTL. It looks like I will need to specify these parameters but it would be great if there was a sensible default?
Whatever you put as TTL yourself, normally the parser should honor the one in the file, so have a look at how each record is printed. The SOA should have a TTL of 900 and all others of 172800.
My problem was the file was saved in unicode encoding and it needed to be ANSI/ASCII.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.