]> mj.ucw.cz Git - nsc-5.git/commitdiff
Added chkdel.
authorMartin Mares <mj@ucw.cz>
Sat, 11 Sep 1999 11:53:27 +0000 (11:53 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 11 Sep 1999 11:53:27 +0000 (11:53 +0000)
NEWS
README
bin/chkdel [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index c3b93fbe485be5fa25557abaedc237e68aff91c2..a7e5dd5fb071037de0156665334d9b54cc113f6a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,3 +6,4 @@ Version 2.2  [11-09-1999]
   o  Added `convert' script for easy conversion of zone files to NSC
      domain files.
   o  Serial numbers are now Y2K clean.
+  o  Added `chkdel' script for checking of zone delegations.
diff --git a/README b/README
index 8922bf872a2b77cb586d2c24eb34120e014cdc11..1a3ef8d36e1b7469eafa155f66b039d76eac0676 100644 (file)
--- a/README
+++ b/README
@@ -190,3 +190,8 @@ chkdom              Checks domains for correctness using the 'host' utility
 convert                A simple perl script for conversion of zone files to NSC
                domain files. Requires the DNS module (available from CPAN at
                ftp.cpan.org).
+
+chkdel         A simple perl script for checking of domain delegations --
+               it checks all PRIMARY and SECONDARY records in cf/domains
+               against NS records. Requires the DNS Perl module and also
+               some tweaking of parameters at the top of the script.
diff --git a/bin/chkdel b/bin/chkdel
new file mode 100755 (executable)
index 0000000..8328201
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/perl -w
+#
+#      ChkDel -- A simple script for checking of domain delegations
+#
+#      (c) 1999 Martin Mares <mj@ucw.cz>
+#
+
+use lib "/home/mj/perl/lib/site_perl";
+
+$our_server = "server1.gts.cz";
+$outside_ns = "ns.eunet.cz";
+
+use Net::DNS::Resolver;
+
+$res = new Net::DNS::Resolver;
+$res->nameservers($outside_ns);
+$res->defnames(0);
+$res->dnsrch(0);
+$res->debug(0);
+$res->recurse(1);
+
+@list = @ARGV ? `cat $ARGV[0]` : `m4 cf/domains`;
+
+foreach $_ (@list) {
+       if (/^PRIMARY\((\S+)\)/) { $dom = $1; }
+       elsif (/^SECONDARY\((\S+)\s*,/) { $dom = $1; }
+       else { next; }
+       $dom eq "localhost" && next;
+#      print "$dom\n";
+       my $q = $res->send($dom, "NS", "IN") or do {
+               print "$dom: ", $res->errorstring, "\n";
+               next;
+       };
+       my $hdr = $q->header;
+       $hdr->tc and do {
+               print "$dom: Truncated response\n";
+               next;
+       };
+       my $rc = $hdr->rcode;
+       $rc eq "NXDOMAIN" and do {
+               print "$dom: Doesn't exist\n";
+               next;
+       };
+       $rc eq "NOERROR" or do {
+               print "$dom: Error $rc\n";
+               next;
+       };
+       $hdr->ancount or do {
+               print "$dom: Empty answer\n";
+               next;
+       };
+       $f = 0;
+       foreach my $r ($q->answer) {
+               if ($r->class eq "IN" && $r->type eq "NS" && $r->nsdname eq $our_server) {
+                       $f = 1;
+                       last;
+               }
+       }
+       $f or do {
+               print "$dom: Lame delegation\n";
+               next;
+       };
+}