#!/usr/bin/perl
#
# This script displays the available vhosts
# on a box

@ifconfig = `/sbin/ifconfig`;

foreach (@ifconfig) { 

if ($_ =~ /inet addr:(.*)  Bcast:(.*)  Mask:(.*)/) { push(@bound,"$1"); }

}


@bound = sort {$b <=> $a} @bound;


foreach (@bound) {
 $host = &getname("$_"); 

#print "$_ 	: $host\n"; 
printf ("%5s : %5s\n", $_, $host, $host);

} 


sub getname
{
        local($host) = @_;
        local(@ary);
        local($ht);
        (@ary) = split(/\./, $host);
        if(scalar(@ary) == 0)
        { return "";}
        else
        {
                $ht = pack("C4", @ary);
                return gethostbyaddr($ht, 2);
        }

}
