I work for an ISP, one of our services is an X.400 ADMD which
has multiple (100s) connections to the outside world, throught VPNs,
framerelay connections, and `normal` Internet connections
Our Application managers wished to see actually HOW the IP connections
left our network.
The information on adjacent MTAs is kept in a file with the format:
MTA=
MTAName=NAME
bla bla=bla
bla bla=bla
...
Addr=<IP Address OR X.25 Address>
...
...
EndMTA
This file was used as input
I whipped up the following in 20 mins, it traceroutes
to our network boundry, resolves network objects, and prints the
route the connection takes (IP addresses, and object names changed
to protect the `innocent`)
#!/usr/bin/perl -w
use strict;
$/="EndMTA";
my %Address;
my %Resolve;
$Resolve{'10.0.0.10'}='Screening_Router';
$Resolve{'10.0.0.15'}='Firewall_1';
$Resolve{'10.0.0.20'}='Firewall_2';
$Resolve{'10.0.0.25'}='Internet_Router';
$Resolve{'10.0.0.30'}='Router_06';
$Resolve{'10.0.0.35'}='Router_05';
$Resolve{'10.0.0.40'}='Router_03';
$Resolve{'10.0.0.45'}='Router_01';
$Resolve{'10.0.0.50'}='Router_11';
while (<>)
{
next unless /MTAName=(\S+).*Addr=(\d+\.\d+\.\d+\.\d+)/so;
$Address{$1}=$2;
};
$/="\n";
for my $Mta (sort keys %Address)
{
my @Data=`traceroute -n -m 3 $Address{$Mta} 2> /dev/null`;
next unless @Data==5;
my @Hop;
push @Hop,(split /\s+/,$_)[2] for ($Data[-3],$Data[-2],$Data[-1]);
print "$Mta ($Address{$Mta}):\t";
print "\t=>\t$_(",$Resolve{$_}||'Unknown',")" for @Hop;
print "\n";
};
I love Perl for quick hacks, and bigger projects... this was a fun hack ;)
GreetZ!,
print "profeth still\n" if /bird|devil/;