Hurricane Electric's IPv6 Tunnel Broker Forums

Advanced search  

News:

Welcome to Hurricane Electric's Tunnelbroker.net forums!

Author Topic: Perl script for daily digs, traceroutes, pings, etc  (Read 4149 times)

tsemczyszyn

  • Newbie
  • *
  • Posts: 5
Perl script for daily digs, traceroutes, pings, etc
« on: June 21, 2010, 12:54:20 PM »

I wrote myself a little Perl script that will take an IPv6-enabled domain as an argument and do each of the daily tests for extra points. It pauses so you can paste the output into the website. I find it quite handy so I thought I'd toss it up here if anyone would like to use it.

Code: [Select]
#!/usr/bin/perl
use IO::Handle;

if (@ARGV != 1) {
  print "You must supply only one argument: the IPv6 domain you wish to use.\n\n";
  exit(1);
}



$domain = $ARGV[0];
@ip_list = `dig AAAA $domain +short`;

foreach (@ip_list) {
  if ($_ =~ /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/ )
  {
     $ip = $_;
     last;
  }
}

if (!$ip_list[0]) {
  print "Not an IPv6-enabled domain\n";
  exit(1);
}

system("clear");
print "Executing traceroute6 to $domain...\n\n\n";

system("traceroute6 $domain");

print "\n\nPress enter to continue...\n\n";
$key = <STDIN>;

system("clear");
print "Executing forward lookup on $domain...\n\n\n";

system("dig AAAA $domain");

print "Press enter to continue...\n\n";
$key = <STDIN>;

system("clear");
print "Executing reverse lookup on $domain's IP...\n\n\n";

system("dig -x $ip");


print "Press enter to continue...\n\n";
$key = <STDIN>;

system("clear");
print "Executing ping6 on $domain...\n\n\n";

system("ping6 -n -c 5 $domain");

print "\n\nPress enter to continue...\n\n";
$key = <STDIN>;

system("clear");
print "Executing whois on $domain's IP...\n\n\n";

system("whois $ip");

print "\n\nPress enter to continue...\n\n";
$key = <STDIN>;

print "That's all for today!\n\n\n";
Logged

bgvaughan

  • Newbie
  • *
  • Posts: 2
Re: Perl script for daily digs, traceroutes, pings, etc
« Reply #1 on: June 29, 2010, 01:49:44 PM »

Thanks!

Out of curiosity, why Perl instead of a BASH shell script or the like?
Logged

jimb

  • Hero Member
  • *****
  • Posts: 807
Re: Perl script for daily digs, traceroutes, pings, etc
« Reply #2 on: June 29, 2010, 10:54:20 PM »

Perlre probably.  Parsing IPv6 addresses can be hairy.  I'd rather do it in Perl also.  :P
Logged