shell ip扫描

#shell script
echo ping扫描
echo 开始扫描...

echo 获取本机IP...

myip=`ifconfig eth0 | awk '{print $2}'|egrep "addr:[0-9]" | awk 'BEGIN {FS=":"} {print $2}'`

echo "本机IP:" $myip

net_ip=${myip%.*}.

echo "网络扫描开始地址:"$net_ip'1'

echo "ping扫描" > ./up_host.txt

for scan_ip in $(seq 1 255)
do
	ping -c 3 $net_ip"$scan_ip" > /dev/null && echo "the host is up----" $net_ip"$scan_ip" && echo $net_ip"$scan_ip">> ./up_host.txt || echo "the host is down--" $net_ip"$scan_ip"
done


你可能感兴趣的:(shell,网络)