有没有一种方法可以从Windows命令行检查特定端口的状态?我知道我可以使用netstat来检查所有端口,但netstat很慢,而查看特定的端口可能不是。
当前回答
netstat -a -n | find /c "10.240.199.9:8080"
它会告诉你在特定IP和端口上活动的套接字的数量(服务器端口号)
其他回答
在linux中: 要找到一个你可以使用的外国端口:
Netstat -anp |grep端口|awk '{print $5}' |grep端口
要查找您可能使用的本地端口:
Netstat -anp |grep端口|awk '{print $4}' |grep端口
Windows 8用户:打开命令提示符,输入netstat -an | find "your port number",输入。
如果回复是LISTENING,那么端口正在使用中,否则它是空闲的。
为了改进@EndUzr的回复:
要查找外部端口(IPv4或IPv6),您可以使用:
netstat -an | findstr /r /c:":N [^:]*$"
要查找本地端口(IPv4或IPv6),您可以使用:
netstat -an | findstr /r /c:":N *[^ ]*:[^ ]* "
其中N为您感兴趣的端口号。“/r”开关告诉它将其作为regexp处理。“/c”开关允许findstr在搜索字符串中包含空格,而不是将空格作为搜索字符串分隔符。这种增加的空间可以防止更长的端口被滥用——例如,“:80”vs“:8080”和其他端口修改问题。
列出到本地RDP服务器的远程连接,例如:
netstat -an | findstr /r /c:":3389 *[^ ]*:[^ ]*"
或者查看谁在触摸您的DNS:
netstat -an | findstr /r /c:":53 *[^ ]*:[^ ]*"
如果你想排除本地端口,你可以使用一系列带有“/v”的异常,并使用反斜杠转义字符:
netstat -an | findstr /v "0.0.0.0 127.0.0.1 \[::\] \[::1\] \*\:\*" | findstr /r /c:":80 *[^ ]*:[^ ]*"
这对你有帮助
netstat -atn | grep <port no> # For tcp
netstat -aun | grep <port no> # For udp
netstat -atun | grep <port no> # For both
我使用:
netstat –aon | find "<port number>"
其中o表示进程ID。 现在你可以对进程ID做任何事情。 要终止进程,例如,使用:
taskkill /F /pid <process ID>
推荐文章
- 我如何找到哪个程序正在使用端口80在Windows?
- 在Windows中有像GREP这样的模式匹配实用程序吗?
- 如何在Windows命令提示符下运行.sh ?
- 如何从命令行在windows中找到mysql数据目录
- 在没有事件源注册的情况下写入Windows应用程序事件日志
- 有效地测试Linux上的端口是否打开?
- 访问HTTP响应作为字符串在Go
- 无法在Windows上从/usr/local/ssl/openssl.cnf加载配置信息
- GIT克隆在windows中跨本地文件系统回购
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 在SSH会话中查找客户端的IP地址
- 为什么这个Windows批处理文件只执行第一行,而在命令shell中执行所有三行?
- 环境变量存储在Windows注册表的哪里?
- 有一个好的Valgrind Windows的替代品吗?