- A+
所属分类:Shell
#!/bin/bash
#适用于 CentOS 系统
# 要扫描的网段
NETWORK="192.168.22.0/24"
# 使用nmap的-sn选项来执行ping扫描
nmap -sn $NETWORK | grep "192.168.22." | cut -d" " -f5 | while read ip; do
ping -c 1 -W 1 $ip > /dev/null
if [ $? -eq 0 ]; then
echo "$ip is alive"
fi
done
