临时检测局域网中未使用的IP地址
#!/bin/bash echo "检测局域网中未使用的IP地址2015" echo "" processbar() { local current=$1; local total=$2; local maxlen=80; local barlen=66; local perclen=14; local format="%-${barlen}s%$((maxlen-barlen))s" local perc="[$current/$total]" local progress=$((current*barlen/total)) local prog=$(for i in `seq 0 $progress`; do printf ‘#‘; done) printf "\r$format" $prog $perc } for i in `seq 1 254`; do processbar $(($i*100/254)) 100 /usr/bin/arping -I eth0 -c 1 192.168.10.$i | grep -B 2 "Received 0" |head -1 >> mac$(date +%Y%m%d).txt ; done
程序中循环进度条参考自:http://blog.csdn.net/wxqee/article/details/38332141
或者使用
#!/bin/bash echo 查找未使用的IP地址,通过检测MAC,来找,如果没有开机,无法找到! for (( i=1 ; i<254; i++ )) do /usr/bin/arping -I eth0 -c 1 192.168.0.$i | grep -B 2 "Received 0" | grep "192.168.0." >>mac$(date +%Y%m%d).txt ; # sleep 3 echo -e "--> $(($i*100/254)) % \c " done echo 100%执行完毕,已输出到当前目录下的mac$(date +%Y%m%d).txt文件,请查看!
时间: 2024-10-06 20:27:13