views:

183

answers:

3

Hi,

FOund the following on: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/

Can unix-masters have a look at it and see if its the best possible way to gather the unique domainsnames in a zone file?

For .NET domains: grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >> netdomains.txt

For .COM domains: grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq >> comdomains.txt

For .EDU domains: grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq >> edudomains.txt

A: 

can you provide a sample of one of those files?

Bryan
A: 

Here is an older example. I compared with mine and the format is still the same.

http://www.adspeed.org/2006/04/parsing-verisign-comnet-zone-files.html

;File start: 95720  
; The use of the Data contained in Verisign Inc.' 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 EDU.  
@ IN    SOA     L3.NSTLD.COM. NSTLD.VERISIGN-GRS.COM. (  
                                  2006040800 ;serial  
                                  1800 ;refresh every 30 min  
                                  900 ;retry every 15 min      
                                  604800 ;expire after a week
                                  86400 ;minimum of a day
                                  )
$TTL 518400
 NS L3.NSTLD.COM.
 NS D3.NSTLD.COM.
 NS A3.NSTLD.COM.
 NS E3.NSTLD.COM.
 NS C3.NSTLD.COM.
 NS G3.NSTLD.COM.
 NS M3.NSTLD.COM.
 NS H3.NSTLD.COM.
L3.NSTLD.COM. A 192.41.162.32
D3.NSTLD.COM. A 192.31.80.32
A3.NSTLD.COM. A 192.5.6.32
E3.NSTLD.COM. A 192.12.94.32
C3.NSTLD.COM. A 192.26.92.32
G3.NSTLD.COM. A 192.42.93.32
M3.NSTLD.COM. A 192.55.83.32
H3.NSTLD.COM. A 192.54.112.32
$TTL 172800
22CF NS DNS1.NAME-SERVICES.COM.
22CF NS DNS2.NAME-SERVICES.COM.
22CF NS DNS3.NAME-SERVICES.COM.
TEST NS NS1.TEST
......

this is a new.zone file example. I added the bottom one so you can see how it is when nameserver is also .net, it leaves it out.

Brandon
+1  A: 

Personally, I'd use named-checkzone to canonicalise the format of the zone file before further processing:

% named-checkzone -i none -s full -D com. com.zone | \
  perl -ane 'print $F[0]."\n" if $F[3] eq "NS"' | \
  uniq

The command line is admittedly longer, but it avoids the need for a potentially fragile regular expression match. The named-checkconf output is guaranteed to have the resource record type (NS) in the fourth field, and the whole domain name in the first field.

FWIW, named-checkzone also sorts the zone file output, which ensures that uniq works properly.

Alnitak