分类: Python/Ruby
2012-02-16 15:43:15
以下脚本比较简单,必须在目标网段中的某一台机器上运行。具体如下:
#!/bin/sh
#检查整个网段主机系统linux/windows/网络设备
ip="192.168.113."
LOG=/root/ip.log
for i in `seq 1 254`
do
ping -c 2 $ip$i > $LOG
okip=`cat $LOG | grep "ttl=" | awk -F'[: =]' '{print $4}'|sort |uniq`
ttl=`cat $LOG | grep "ttl=" | awk -F'[: =]' '{print $9}'|sort |uniq`
if [ $ttl -eq 64 ];then
echo -e "\e[32mcheck $okip is linux主机\e[0m"
elif [ $ttl -eq 128 ];then
echo -e "\e[32mcheck $okip is windows主机\e[0m"
else
echo -e "\e[32mcheck $okip is VIP/网络设备/其他\e[0m"
fi
done