Simple Network Discovery
The bash script below will scan the specified IP range and use dig and nmap to try to determine the fully-qualified domain name, type and the operating environment of any device that responds to network pings. You can add the “–osscan-guess” option to the nmap command to enable the “guessing” mode for the OS type.
#!/bin/bash
echo -e "IPtFQDNtDevice TypetOS TypetOS Details"
for i in `echo 192.168.{1.255}.{1..255}`
do
if [ `ping -w 1 -c 1 $i >/dev/null 2>&1 ; echo $?` -eq 0 ]
then
echo -ne "${i}t"
node=$(dig +short -x ${i} | head -1 | sed -e 's/.$//g' 2>/dev/null)
if [ -z ${node} ]
then
node=unknown
fi
echo -ne "${node}t"
nmap -O -v ${i} | egrep -i "^Device type:|^Running:|^OS Details:|^Aggressive OS" |
awk -F':' '{print $2}' | sed -e 's/^ //g' -e 's/(.[0-9]%)//g' -e 's/|/, /g' | while read line
do
echo -ne "${line}t"
done
echo ""
fi
done

