当前位置: 代码迷 >> 综合 >> 扫描内网所有主机,获取MAC地址
  详细解决方案

扫描内网所有主机,获取MAC地址

热度:93   发布时间:2024-01-17 20:41:33.0

该脚本是用来扫描网段内存活主机,并自动保存其mac地址。

#/bin/bash
#扫描内网所有主机,获取MAC地址ETH=$(ifconfig | grep "eth" | awk '{print $1}')
NET="192.168.0"for((i=1;i<255;i++))
dores=$(arping -c 2 -w 1 $NET.$i -I $ETH | grep "reply from" | awk '{print $4","$5}')#echo $restest -z $resif [ $? -eq 1 ]thenecho "$res" >> mac.txtecho "$NET.$i的MAC地址已写入mac.txt"elseecho "$NET.$i is down"fi
done
echo "finish"

 

  相关解决方案