<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/env perl

use strict;
use warnings;

use Net::DNS;

my $RR_DIR = '/etc/bind/SEC';
my @nameServers = qw/9.9.9.9 1.1.1.1 8.8.8.8 8.8.4.4 149.112.112.112 208.67.222.222 208.67.220.220 1.0.0.1 64.6.64.6 64.6.65.6/;

sub getNSRecords {
   my $domain = shift;
   use Net::DNS;
   # run the following with a name server randomly chosen from @nameServers
   my $res   = Net::DNS::Resolver-&gt;new (nameserver =&gt; ($nameServers[rand @nameServers]) );
   my $reply = $res-&gt;query($domain, "NS");
   my @result = ();
 
   if ($reply) {
      foreach my $rr (grep { $_-&gt;type eq "NS" } $reply-&gt;answer) {
         #print $rr-&gt;nsdname, "\n";
         push @result,$rr-&gt;nsdname;
      }
   } else {
      warn "query failed for [$domain]: ", $res-&gt;errorstring, "\n";
   }
   return \@result;
}


my @domains = `ls $RR_DIR`;
chomp @domains;

#print join( "\n", @{ &amp;getNSRecords( "dailydata.net" ) }) . "\n";
#die;

my %results;
my $count = 0;

foreach my $domain (sort @domains) {
   print STDERR '.';
   next if $domain =~ m/\.arpa$/;
   my $ns = &amp;getNSRecords( $domain );
   if ( $ns &amp;&amp; scalar (@$ns) ) {
      foreach my $thisNS ( @$ns ) {
         push @{ $results{$thisNS} }, $domain;
      }
   } else {
      push @{ $results{'Unknown'} }, $domain;
   }
   sleep(1);
#   last if $count++ &gt; 10;
}

foreach my $ns ( sort keys %results ) {
   print "$ns\n";
   print "\t", join( "\n\t", @{ $results{$ns} } ) . "\n";
}

1;
</pre></body></html>