Hurricane Electric's IPv6 Tunnel Broker Forums
June 18, 2013, 03:05:28 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Hurricane Electric's Tunnelbroker.net forums!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Perl script for daily digs, traceroutes, pings, etc  (Read 1750 times)
tsemczyszyn
Newbie
*
Posts: 5


View Profile
« 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:
#!/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


View Profile
« 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: 804


^^^ Warped picture


View Profile
« 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.  Tongue
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!