简单shell实现局域网IP扫描

#!/bin/bash
network=$1
time=$(date +%H%M%S)
for i in $(seq $2 $3)
do
    ping -c 1 -w 2 $network.$i > /dev/null
    if [ $? -eq 0 ]; then
          arp $network.$i | grep ":" | awk '{print $1,$3}' >> $time.log
          echo "host $network.$i is up"
   else
          echo "host $network.$i is down"
   fi
done

 

执行命令:

./netscan.sh 10.200.201 100 200

表示扫描10.200.201.100-10.200.201.200IP是否存活
posted @ 2019-03-18 10:43  风一点一点的吹  阅读(...)  评论(...编辑  收藏