shell - 扫描局域网24位网段IP
2022-06-05
扫描24位网段所有ip,判断可用性
#!/bin/bash
function checkPortStatus(){
port=$1
nmap ${line} -p ${port} | grep open > /dev/null
if [[ $? -eq 0 ]];then
echo ${line} "${port} is open"
else
echo ${line} "${port} is close"
fi
}
port=$1
if [[ -z ${port} ]];then
exit 1
fi
cat /tmp/ping-all | grep online | awk '{print $1}'| while read line
do
checkPortStatus ${port}
done