#!/bin/perl #Output the IP address (and domain name, if there is one) #of every host on the local network use Socket; $_ = `/sbin/ifconfig -a | grep -w inet | grep -v '127\.0\.0\.1'`; chomp; @_ = split; $netmask = hex($_[3]); $ip = inet_aton($_[5]) or die "$0: bad broadcast address $_[5]"; $ibroadcast = unpack('N', $ip); for ($i = ($ibroadcast & $netmask) + 1; $i < $ibroadcast; ++$i) { $ip = pack('N', $i); print inet_ntoa($ip); $name = gethostbyaddr($ip, AF_INET); if (defined $name) { print " $name"; } print "\n"; } exit 0;