Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 38d14bd2d5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 262 lines (214 sloc) 5.875 kb
#!/usr/bin/perl
use strict;
use Net::DNS;
use Getopt::Std;
my %opts;
my %domaininfo;
my %countinfo;
my $ipv6tests = 3;
my $dnssectests = 2;
if (!getopt('vh', \%opts)) {
usage();
exit 1;
}
if ($opts{'h'} || $#ARGV == -1) {
usage();
exit 1;
}
my $resolver = Net::DNS::Resolver->new;
$| = 1; # immediate flush
print "<table>\n";
my $headerstyle="style=\"border: 1px solid black; border-width: 0px 0px 2px 0px;\"";
print "<thead><tr><th>&nbsp;</th><th colspan=\"$ipv6tests\" $headerstyle>IPv6</th><th colspan=\"2\" $headerstyle>DNSSEC</th></tr></thead>\n";
print "<thead><tr><th $headerstyle>Domain</th><th>DNS</th><th>WWW</th><th>MX</th><th>DNSKEY</th><th>DS</th></tr></thead>\n";
print "<tdata>\n";
foreach my $domain (@ARGV) {
# strip any www. prefix
$domain =~ s/^www\.//;
Verbose("Checking $domain\n");
print " <tr>\n <td><a href=\"http://www.$domain/\">$domain</a></td>\n";
# IPv6 tests
$domaininfo{$domain}{'total'} +=
(check_for_NS($domain) ? 1 : 0);
$domaininfo{$domain}{'total'} +=
(check_for_AAAA("www." . $domain, 1) ? 1 : 0);
$domaininfo{$domain}{'total'} +=
(check_for_MX($domain) ? 1 : 0);
# count the IPv6 results
$domaininfo{$domain}{'ipv6'} = $domaininfo{$domain}{'total'};
$countinfo{'ipv6'}{$domaininfo{$domain}{'total'}}++;
# DNSSEC tests
$domaininfo{$domain}{'total'} +=
(check_for_generic($domain, 'DNSKEY') ? 1 : 0);
$domaininfo{$domain}{'total'} +=
(check_for_generic($domain, 'DS') ? 1 : 0);
# count the DNSSEC results
$domaininfo{$domain}{'dnssec'} =
$domaininfo{$domain}{'total'} - $domaininfo{$domain}{'ipv6'};
$countinfo{'dnssec'}{$domaininfo{$domain}{'dnssec'}}++;
print " </tr>\n";
}
print "</tdata></table>\n";
print "<hr />\n";
#
# Print the gold star summary results
#
print "<table>\n <thead>\n";
print " <tr><th>&nbsp;</th><th colspan=\"4\">Good Results Counts</th></tr>\n";
print " <tr><th>&nbsp;</th><th>0</th><th>1</th><th>2</th><th>3</th></tr></thead>\n";
print "<tdata>\n";
print " <tr>\n <th>IPv6</th>\n";
foreach my $count (0..$ipv6tests) {
print " <td>$countinfo{ipv6}{$count}</td>\n";
}
print " <tr>\n <th>DNSSEC</th>\n";
foreach my $count (0..$dnssectests) {
print " <td>$countinfo{dnssec}{$count}</td>\n";
}
print "</tdata></table>\n";
#
# Print the list of gold starts themselves
#
print "<hr />\n";
print "<table>\n";
print "<thead><tr><th>Domain</th><th>IPv6</th><th>DNSSEC</th><th>Both</th></thead>\n";
print " <tdata>\n";
foreach my $domain (sort keys(%domaininfo)) {
if ($domaininfo{$domain}{'ipv6'} == $ipv6tests ||
$domaininfo{$domain}{'dnssec'} == $dnssectests) {
# they qualify for at least one...
print " <tr>\n <td>$domain</td>\n";
# IPv6
if ($domaininfo{$domain}{'ipv6'} == $ipv6tests) {
print " <td>YES</td>\n";
} else {
print " <td>NO</td>\n";
}
# DNSSEC
if ($domaininfo{$domain}{'dnssec'} == $dnssectests) {
print " <td>YES</td>\n";
} else {
print " <td>NO</td>\n";
}
# BOTH
if ($domaininfo{$domain}{'ipv6'} == $ipv6tests &&
$domaininfo{$domain}{'dnssec'} == $dnssectests) {
print " <td>YES</td>\n";
} else {
print " <td>NO</td>\n";
}
print " </tr>\n";
}
}
print "</tdata></table>\n";
use Data::Dumper;
print STDERR Dumper(\%countinfo);
#######################################################################
# Test Functions
#
sub check_for_NS {
my ($name) = @_;
my $count = 0;
Verbose(" checking NS records\n");
# Find the list of MX records for a name
my $query = $resolver->search($name, "NS");
if ($query) {
foreach my $record ($query->answer) {
# for each NS record, find at least one that has an IPv6 address
$count += check_for_AAAA($record->nsdname);
}
}
if ($count > 0) {
Succeed($count);
return $count;
}
# if we got here for any reason, we've failed
Fail();
return 0;
}
sub check_for_MX {
my ($name) = @_;
my $count = 0;
Verbose(" checking MX records\n");
# Find the list of MX records for a name
my $query = $resolver->search($name, "MX");
if ($query) {
foreach my $record ($query->answer) {
# for each MX record, find at least one that has an IPv6 address
$count += check_for_AAAA($record->exchange);
}
}
if ($count > 0) {
Succeed($count);
return $count;
}
# if we got here for any reason, we've failed
Fail();
return 0;
}
sub check_for_AAAA {
my ($name, $printresults) = @_;
my $count = 0;
# test for an AAAA record for whatever was passed in
my $query = $resolver->search($name, "AAAA");
if ($query) {
foreach my $record ($query->answer) {
next unless $record->type eq "AAAA";
Verbose(" found an AAAA record for $name");
$count++;
}
if ($count > 0) {
if ($printresults) {
Succeed($count);
}
return $count;
}
} else {
Verbose(" Query failed: ", $resolver->errorstring, "\n");
}
if ($printresults) {
Fail();
}
return 0;
}
sub check_for_generic {
my ($name, $type) = @_;
my $count = 0;
Verbose(" checking $type records\n");
# Find the list of MX records for a name
my $query = $resolver->search($name, $type);
if ($query) {
foreach my $record ($query->answer) {
$count++;
}
}
if ($count > 0) {
Succeed($count);
return $count;
}
# if we got here for any reason, we've failed
Fail();
return 0;
}
sub Succeed {
my ($addr) = @_;
print " <td bgcolor=\"40ff40\">$addr</td>\n";
}
sub Fail {
my ($record) = @_;
print " <td bgcolor=\"red\">0</td>\n";
}
sub Warn {
print STDERR @_;
}
sub Verbose {
if ($opts{'v'}) {
print STDERR @_;
}
}
sub usage {
print "ipv6day [-v] [-t] DOMAINS\n\n";
print "Options:\n";
print "\t-v\tVerbose Mode\n";
print "\t-h\tHelp\n";
}
Jump to Line
Something went wrong with that request. Please try again.