shellscript-14-检测网段内在线ip
脚本内容
#!/bin/bash
# author: yolo
# 检测网段内在线ip,并罗列 示例网段:192.168.10.0/24
# 遍历网段1到254
for i in `seq 1 254`
do
# 如果ping通,执行成功条件为真
# -c 2 ping两次 -W 2 指定超时时间
if ping -c 2 -W 2 192.168.10.$i >/dev/null 2>/dev/null
then
echo "192.168.0.$i 通" >> ip.txt
else
echo "192.168.0.$i 不通" >> ip.txt
fi
done
标签:网段,14,ip,ping,192.168,echo,在线
From: https://blog.51cto.com/u_13241097/8599492