批量telnet检查 ip 端口状态

我们知道,使用telnet命令可以检查一个ip的端口的通畅状态。这里分享一下批量查询的方法。

1.需要下载一个命令行exe程序,微软官方出的的扫描器,叫PortQry。

2.在PortQry.exe同目录下,新建一个文本文档,如ips.txt,用于存放ip 端口列表。具体格式为ip地址,空格,端口号。一行一条。

3.同目录下,新建一个文本文档,文件名改为scan.bat,把下面的代码粘贴进去,
@echo off
@setlocal enabledelayedexpansion
@if exist notopen.log del /f /q notopen.log
@if exist open.log del /f /q open.log
@for /f "tokens=1,2* delims= " %%i in (ips.txt) do (
@portqry -n %%i -e %%j|find ": LISTENING" >nul
@if !errorlevel!==0 (
@echo %%i:%%j >>open.log
) else (
@echo %%i:%%j >>notopen.log
)
)

4.每次检查的时候,运行一下scan.bat,等窗口自动消失后,结果会输出到log文件。端口通的在open.log,不通的在notopen.log。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注