端口连通测试工具
一、 telent
网上资料讲的最多也用的最多的方法,缺点是新手可能不知道怎么退出,不连通的端口不方便设置超时,不适用于遍历。
- 连通后按
ctrl+]
进入交互 - 再输入
quit
按回车后退出
二、curl
curl host:ip
可以用但不推荐,有些情况下不管端口是否连通输入命令没有任何响应
三、wget
wget [options] [url] 实际测试参数放在url后时也暂未发现问题
常用参数wget -h
Startup:
-V, --version display the version of Wget and exit.
-h, --help print this help.
...
Download:
-t, --tries=NUMBER set number of retries to NUMBER (0 unlimits).
--retry-connrefused retry even if connection is refused.
... local.
-T, --timeout=SECONDS set all timeout values to SECONDS.
--dns-timeout=SECS set the DNS lookup timeout to SECS.
--connect-timeout=SECS set the connect timeout to SECS.
--read-timeout=SECS set the read timeout to SECS.
...
# 为节省篇幅 此处只复制了用到的参数 更多参数的详细解释请自行查看~
-t 设置尝试的此处 0表示一直尝试
-T 单次连接try的超时时间
【示例:寻找某服务器1-10000端口中开放的端口】
借助命令"seq 10000"获取到1-10000的整数 用于遍历
# 超快遍历
for i in `seq 10000`
do
# echo $i
wget xxxx:$i -T 1 -t 1 2>&1 | grep response &
done
# 写作一行时 设置后台执行的&后不能加;
# 尝试此处和超时均设置为1
# "grep response"是为了避免打印过多日志 大家可以先放开对输出进行确认 制定合适的过滤词
# 2>&1 表示将错误输出重定向到标准输出 上面grep的response所在的行其实是由错误输出输出的
for i in `seq 10000`; do wget x.x.x.x:$i -T 1 -t 1 2>&1 | grep response & done
执行完后可按两次回车 让所有的挂起后台任务的完成日志打印完