#!/usr/bin/perl -w use strict; use Net::DNS; use Net::Traceroute; my $host = $ARGV[0]; # Set up DNS my $res = Net::DNS::Resolver->new; print "This can take a while... please be patient.\n"; my $traceroute = new Net::Traceroute(host => "$host"); print "Okay, here are the results...\n"; my $hops = $traceroute->hops; print "It took $hops hops to get there.\n"; my $i; for($i = 0; $i<$hops; $i++) { if(defined($traceroute->hop_query_host($i,0))) { my $remote_host = $traceroute->hop_query_host($i,0); print "Hop $i: $remote_host:\n"; if($remote_host =~ m/(\d+)\.(\d+)\.(\d+)\.(\d+)/) { my $reverse_host = "$4.$3.$2.$1"; my $rr; my $query = $res->query("${reverse_host}.in-addr.arpa",'PTR'); if($query) { foreach($query->answer) { if($_->type eq 'PTR') { print " ... found DNS PTR record for $reverse_host: " . ($_->ptrdname) . "\n"; } } } # courtesy of CYMRU $query = $res->query("${reverse_host}.origin.asn.cymru.com",'TXT'); if($query) { foreach($query->answer) { my $rr = $_; if($rr->type eq 'TXT') { print " ... found CYMRU TXT record for $reverse_host.origin.asn.cymru.com: " . ($rr->txtdata) . "\n"; } # finally, try for an ASN description at asn.cymru.com my($asn,@rest) = split(/\|/,$rr->txtdata); $asn =~ s/ //g; $query = $res->query("AS${asn}.asn.cymru.com",'TXT'); foreach($query->answer) { my $rr = $_; if($rr->type eq 'TXT') { print " ... found CYMRU ASN description for asn AS$asn: " . ($rr->txtdata) . "\n"; } } } } } } }