Skip to content

Commit

Permalink
Add some very old dns checking scripts for completeness.
Browse files Browse the repository at this point in the history
  • Loading branch information
deanwilson committed Oct 31, 2015
1 parent c91a621 commit a8b3864
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
29 changes: 29 additions & 0 deletions check-nsservers-know
@@ -0,0 +1,29 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use Net::DNS;

# takes a single domain, retrieves the ns records for it and then
# queries each server to ensure it can answer for that domain

my $domain = shift;

my $res = Net::DNS::Resolver->new;
my $query = $res->query( $domain, "NS");

if ($query) {
foreach my $rr (grep { $_->type eq 'NS' } $query->answer) {
$res->nameservers( $rr->nsdname);

my $lookup = $res->query( $domain, "A");
if ($lookup) {
foreach my $record (grep { $_->type eq 'A' } $lookup->answer) {
print $domain, " ", $rr->nsdname, " ", $record->address, "\n";
}
} else {
warn "A record query for [$domain] against [", $rr->nsdname, "] failed: ", $res->errorstring, "\n";
}
}
} else {
warn "NS record query for [$domain] failed : ", $res->errorstring, "\n";
}
24 changes: 24 additions & 0 deletions check-subdomains-presence
@@ -0,0 +1,24 @@
#!/usr/bin/perl
use strict;
use warnings;
use Net::DNS;

die "$0: please supply a subdomain to look for and one or more zones to look in\n"
unless @ARGV >= 2;

my $domain = shift;
my @zones = @ARGV;

my $res = Net::DNS::Resolver->new;

for my $zone ( @zones ) {
my $query = $res->query( "$domain.$zone", "A");

if ( $query ) {
foreach my $rr ( grep { $_->type eq 'A' } $query->answer ) {
print "Present - $domain.$zone\n";
}
} else {
warn "Absent - $domain.$zone - ", $res->errorstring, "\n";
}
}
25 changes: 25 additions & 0 deletions domain_expiry.pl
@@ -0,0 +1,25 @@
#!/usr/bin/perl
use strict;
use warnings;
use Net::Domain::ExpireDate;

die "$0: <file of domainnames>\n" unless @ARGV == 1;

my $domainfile = shift;

open( my $domains_fh, '<', $domainfile )
|| die "Failed to open [$domainfile]: $!\n";

my %domain_expiry;
for my $domain ( sort <$domains_fh> ) {
my $expiration = expire_date( $domain, '%Y-%m-%d' );

$expiration ||= "unknown";

push @{ $domain_expiry{$expiration} }, $domain;
}

for my $expiry_date (sort keys %domain_expiry) {
print "$expiry_date -\n";
print " -- $_" for @{ $domain_expiry{$expiry_date} };
}

0 comments on commit a8b3864

Please sign in to comment.