Revision 2 (by moose, 2008/11/28 19:56:31) initial import
#!/usr/bin/perl
 use strict;
 use Socket;
 use Net::netent;

 @ARGV = ('loopback') unless @ARGV;

 my($n, $net);

 for $net ( @ARGV ) {

     unless ($n = getnetbyname($net)) {
        warn "$0: no such net: $net\n";
        next;
     }

     printf "\n%s is %s%s\n", 
            $net, 
            lc($n->name) eq lc($net) ? "" : "*really* ",
            $n->name;

     print "\taliases are ", join(", ", @{$n->aliases}), "\n"
                if @{$n->aliases};     

     # this is stupid; first, why is this not in binary?
     # second, why am i going through these convolutions
     # to make it looks right
     {
        my @a = unpack("C4", pack("N", $n->net));
        shift @a while @a && $a[0] == 0;
        printf "\taddr is %s [%d.%d.%d.%d]\n", $n->net, @a;
     }

     if ($n = getnetbyaddr($n->net)) {
        if (lc($n->name) ne lc($net)) {
            printf "\tThat addr reverses to net %s!\n", $n->name;
            $net = $n->name;
            redo;
        } 
     }
 }