From 2591edefbe9974a62d3845d023c2027fa675e438 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 11 Sep 1999 11:53:27 +0000 Subject: [PATCH 1/1] Added chkdel. --- NEWS | 1 + README | 5 +++++ bin/chkdel | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100755 bin/chkdel diff --git a/NEWS b/NEWS index c3b93fb..a7e5dd5 100644 --- 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 8922bf8..1a3ef8d 100644 --- 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 index 0000000..8328201 --- /dev/null +++ b/bin/chkdel @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w +# +# ChkDel -- A simple script for checking of domain delegations +# +# (c) 1999 Martin Mares +# + +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; + }; +} -- 2.39.2