#! /bin/bash # All ip/host name list bcast=`/sbin/ifconfig |sed -e '/Bcast/{s/^.*Bcast://;s/Mask.*$//p}' -n` echo "Broadcast address ${bcast}" ping -c4 -b $bcast >/dev/null 2>&1 /sbin/arp -a 2>/dev/null | awk '{ sub("^.+[(]","");sub("[)].*$",""); ip=$0; split( ip, ot, "." ); printf "%03d.%03d.%03d.%03d:%s\t",ot[1],ot[2],ot[3],ot[4],ip; cmd = sprintf("dig -x %s", ip); while( cmd | getline ){ if( /^;/ ) { continue; }; if( /PTR/) { print $NF; }; } }' | sort -n | cut -d: -f2-