扫描端口脚本

#!/bin/bash
#测试端口


ip="121.12.*.*"



function test_port()
{
min_port=$1
max_port=$2
while [ $min_port -le $max_port ]
do
	
	nc -v -z -w 3  $ip $min_port > /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "$min_port:ok \c"
	else
		echo $min_port:"fail"
	fi
	
	min_port=`expr $min_port + 1`	
done
echo "------------------"
}


test_port 8101 8111
test_port 8201 8206
test_port 8301 8306
test_port 8401 8404
test_port 8901 8910
test_port 8921 8922
test_port 8931 8932
test_port 8941 8944
test_port 8601 8603
test_port 8701 8704
test_port 8801 8803
test_port 9771 9772
test_port 9661 9664

[root@localhost ~]# ./test_port.sh 
8101:ok8102:ok8103:ok8104:ok8105:ok8106:ok8107:ok8108:ok8109:ok8110:ok8111:ok------------------
8201:ok8202:ok8203:ok8204:ok8205:ok8206:ok------------------
8301:ok8302:ok8303:ok8304:ok8305:ok8306:ok------------------
8401:ok8402:ok8403:ok8404:ok------------------
8901:ok8902:ok8903:ok8904:ok8905:ok8906:ok8907:ok8908:ok8909:ok8910:ok------------------
8921:ok8922:ok------------------
8931:ok8932:ok------------------
8941:ok8942:ok8943:ok8944:ok------------------
8601:ok8602:ok8603:ok------------------
8701:ok8702:ok8703:fail
8704:ok------------------
8801:ok8802:ok8803:ok------------------
9771:ok9772:ok------------------
9661:ok9662:ok9663:ok9664:ok------------------






  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值