大家好,又见面了,我是你们的朋友全栈君。
1.查找本机上的端口使用情况
netstat -an
2.查找指定端口的使用情况
C:\Windows\System32>netstat -ano | find “8002”
TCP 0.0.0.0:8002 0.0.0.0:0 LISTENING 2884
TCP [::]:8002 [::]:0 LISTENING 2884
参数说明:
-a 列出所有的
-n 数字的形式列出
-o 显示进程编号
输出结果:
第一列是协议类型,第二列是local address,第三列是remote address,第四列是状态,最后一列是进程编号
2.1找到占用端口的应用程序
查找结果的最后一列是进程编号,可以在任务管理器里找到对应的进程
C:\Windows\System32\inetsrv>netstat -ano | find “8080”
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 2564
TCP 172.31.212.108:54133 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60264 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60266 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60267 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60268 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60304 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60307 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60320 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60324 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60333 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60337 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60341 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60342 172.16.210.31:8080 ESTABLISHED 11820
TCP 172.31.212.108:60344 172.16.210.31:8080 ESTABLISHED 11820
TCP 172.31.212.108:60345 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60346 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60347 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60349 172.16.210.31:8080 TIME_WAIT 0
TCP 172.31.212.108:60354 172.16.210.31:8080 CLOSE_WAIT 17116
TCP 172.31.212.108:60355 172.16.210.31:8080 CLOSE_WAIT 17116
TCP 172.31.212.108:60356 172.16.210.31:8080 ESTABLISHED 7540
TCP 172.31.212.108:60358 172.16.210.31:8080 ESTABLISHED 7540
TCP 172.31.212.108:60365 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60369 172.16.210.31:8080 FIN_WAIT_2 6804
TCP 172.31.212.108:60390 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60392 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60400 172.16.210.31:8080 FIN_WAIT_2 6804
TCP 172.31.212.108:60405 172.16.210.31:8080 FIN_WAIT_2 6804
TCP 172.31.212.108:60406 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60422 172.16.210.31:8080 FIN_WAIT_2 6804
TCP 172.31.212.108:60447 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60459 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60460 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60469 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60474 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60481 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60484 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60485 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60486 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60487 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60488 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60490 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60492 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60495 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60497 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60499 172.30.115.41:8080 ESTABLISHED 11876
TCP 172.31.212.108:60501 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60504 172.30.115.41:8080 TIME_WAIT 0
TCP 172.31.212.108:60514 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60515 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60516 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60517 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60518 172.16.210.31:8080 ESTABLISHED 6804
TCP 172.31.212.108:60519 172.16.210.31:8080 ESTABLISHED 6804
TCP [::]:8080 [::]:0 LISTENING 2564
TCP [::1]:8080 [::1]:60363 TIME_WAIT 0
TCP [::1]:8080 [::1]:60366 TIME_WAIT 0
TCP [::1]:8080 [::1]:60367 TIME_WAIT 0
TCP [::1]:8080 [::1]:60424 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60425 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60426 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60427 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60428 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60429 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60508 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60509 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60510 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60511 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60512 ESTABLISHED 2564
TCP [::1]:8080 [::1]:60513 ESTABLISHED 2564
TCP [::1]:60364 [::1]:8080 TIME_WAIT 0
TCP [::1]:60424 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60425 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60426 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60427 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60428 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60429 [::1]:8080 ESTABLISHED 11876
TCP [::1]:60508 [::1]:8080 ESTABLISHED 6804
TCP [::1]:60509 [::1]:8080 ESTABLISHED 6804
TCP [::1]:60510 [::1]:8080 ESTABLISHED 6804
TCP [::1]:60511 [::1]:8080 ESTABLISHED 6804
TCP [::1]:60512 [::1]:8080 ESTABLISHED 6804
TCP [::1]:60513 [::1]:8080 ESTABLISHED 6804
https://serverfault.com/questions/342481/understanding-the-netstat-command-output
from netstat -h
:
-a Displays all connections and listening ports.
As in both current connections and listening ports (half open).
-n Displays addresses and port numbers in numerical form.
As in, do not resolve addresses to host names.
Your computer can and regularly does connect to itself, usually for IPC or administrative tasks.
*.*
= All IPv4 addresses (it’s listening, so accept connections from any IPv4)[::]
= All IPv6 addresses (same reason as the last).
3.使用图形界面查看
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/155392.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...