检测端口是否开启脚本

首先本机安装好nmap,yum搭建好

#!/bin/bash

for i in 23 24
do
        nmap -n -p 22,80,111,53 192.168.30.$i | grep -E "tcp|udp"
done

检测本机IP状态 创建文件iplist 添加IP本机的
#!/bin/bash
for ip in $(cat /root/iplist)
do
        ping -c 2 -i 0.2 -w 3 $ip &> /dev/null
        if [ $? -eq 0 ]
        then
                echo "Host $ip is up"
        else
                echo "Host $ip isdown"
        fi
done

检测本机的网段
#!/bin/bash

for ip in 192.168.30.{20..150}
do
        ping -c 2 -i 0.2 -w 3 $ip &> /dev/null
        if [ $? -eq 0 ]
        then
                echo "Host $ip is up "
        else
                echo "Host $ip is down"
        fi
done

猜你喜欢

转载自www.cnblogs.com/zc1741845455/p/10884820.html
0条评论
添加一条新回复