windows下的端口监听命令 netstat,下面是这条命令的介绍
C:\>netstat /?
显示协议统计和当前 TCP/IP 网络连接。
NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-t] [interval]
-a 显示所有连接和侦听端口。
-b 显示在创建每个连接或侦听端口时涉及的可执行程序。
在某些情况下,已知可执行程序承载多个独立的
组件,这些情况下,显示创建连接或侦听端口时涉
及的组件序列。此情况下,可执行程序的名称
位于底部[]中,它调用的组件位于顶部,直至达
到 TCP/IP。注意,此选项可能很耗时,并且在您没有
足够权限时可能失败。
-e 显示以太网统计。此选项可以与 -s 选项结合使用。
-f 显示外部地址的完全限定域名(FQDN)。
-n 以数字形式显示地址和端口号。
-o 显示拥有的与每个连接关联的进程 ID。
-p proto 显示 proto 指定的协议的连接;proto 可以是下列任
何一个: TCP、UDP、TCPv6 或 UDPv6。如果与 -s 选
项一起用来显示每个协议的统计,proto 可以是下列任
何一个: IP、IPv6、ICMP、ICMPv6、TCP、TCPv6、UDP
或 UDPv6。
-r 显示路由表。
-s 显示每个协议的统计。默认情况下,显示
IP、IPv6、ICMP、ICMPv6、TCP、TCPv6、UDP 和 UDPv6
的统计;-p 选项可用于指定默认的子网。
-t 显示当前连接卸载状态。
interval 重新显示选定的统计,各个显示间暂停的间隔秒数。
按 CTRL+C 停止重新显示统计。如果省略,则 netstat
将打印当前的配置信息一次。
常用的查看命令
netstat -ano 查看所有连接的PID及端口号
C:\>netstat -ano
活动连接
协议 本地地址 外部地址 状态 PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 892
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:902 0.0.0.0:0 LISTENING 2844
TCP 0.0.0.0:912 0.0.0.0:0 LISTENING 2844
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING 568
TCP 0.0.0.0:1026 0.0.0.0:0 LISTENING 996
TCP 0.0.0.0:1027 0.0.0.0:0 LISTENING 368
TCP 0.0.0.0:1028 0.0.0.0:0 LISTENING 632
TCP 0.0.0.0:1029 0.0.0.0:0 LISTENING 692
TCP 0.0.0.0:2442 0.0.0.0:0 LISTENING 6116
TCP 0.0.0.0:18386 0.0.0.0:0 LISTENING 6116
TCP 0.0.0.0:27275 0.0.0.0:0 LISTENING 1292
TCP 127.0.0.1:5849 127.0.0.1:5850 ESTABLISHED 3508
TCP 127.0.0.1:5850 127.0.0.1:5849 ESTABLISHED 3508
TCP 127.0.0.1:5865 127.0.0.1:5866 ESTABLISHED 3508
TCP 127.0.0.1:5866 127.0.0.1:5865 ESTABLISHED 3508
TCP 127.0.0.1:6492 127.0.0.1:18186 ESTABLISHED 6348
TCP 127.0.0.1:6510 127.0.0.1:18186 ESTABLISHED 6348
TCP 127.0.0.1:6593 127.0.0.1:18186 ESTABLISHED 6336
TCP 127.0.0.1:6594 127.0.0.1:18186 CLOSE_WAIT 6336
TCP 127.0.0.1:6627 127.0.0.1:18186 ESTABLISHED 6772
TCP 127.0.0.1:6664 127.0.0.1:18186 ESTABLISHED 6336
TCP 127.0.0.1:6684 127.0.0.1:18186 ESTABLISHED 6772
TCP 127.0.0.1:6720 127.0.0.1:18186 ESTABLISHED 6772
TCP 127.0.0.1:6722 127.0.0.1:18186 ESTABLISHED 6772
TCP 127.0.0.1:6738 127.0.0.1:18186 ESTABLISHED 6772
TCP 127.0.0.1:18186 0.0.0.0:0 LISTENING 2696
TCP 127.0.0.1:18186 127.0.0.1:6492 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6510 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6593 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6594 FIN_WAIT_2 2696
TCP 127.0.0.1:18186 127.0.0.1:6597 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6599 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6601 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6602 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6603 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6605 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6607 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6609 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6613 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6615 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6616 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6617 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6618 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6627 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6629 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6631 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6635 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6649 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6664 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6684 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6686 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6700 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6720 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6722 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6738 ESTABLISHED 2696
TCP 127.0.0.1:18186 127.0.0.1:6740 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6748 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6750 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6752 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6754 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6756 TIME_WAIT 0
TCP 127.0.0.1:18186 127.0.0.1:6758 TIME_WAIT 0
TCP 127.0.0.1:27275 0.0.0.0:0 LISTENING 1292
TCP 169.254.156.64:139 0.0.0.0:0 LISTENING 4
TCP 192.168.1.104:139 0.0.0.0:0 LISTENING 4
TCP 192.168.1.104:1274 77.234.41.61:80 ESTABLISHED 1292
TCP 192.168.1.104:2430 42.120.143.56:16000 ESTABLISHED 6116
TCP 192.168.1.104:2486 221.176.28.61:8080 ESTABLISHED 5444
TCP 192.168.1.104:5209 180.149.132.15:80 CLOSE_WAIT 2696
TCP 192.168.1.104:5213 180.149.132.15:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6115 220.181.94.203:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6116 220.181.94.203:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6186 220.181.90.240:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6188 220.181.90.240:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6189 220.181.94.202:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6192 220.181.90.21:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6193 220.181.90.21:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6494 117.79.157.201:80 ESTABLISHED 2696
TCP 192.168.1.104:6511 117.79.157.251:80 ESTABLISHED 2696
TCP 192.168.1.104:6512 117.79.157.225:443 CLOSE_WAIT 6348
TCP 192.168.1.104:6560 59.151.61.62:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6562 119.254.26.150:80 LAST_ACK 2696
TCP 192.168.1.104:6563 123.150.53.161:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6564 123.150.53.161:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6568 59.151.61.61:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6569 59.151.16.185:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6570 59.151.16.185:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6574 59.151.61.61:80 CLOSE_WAIT 2696
TCP 192.168.1.104:6595 115.239.211.110:80 ESTABLISHED 2696
TCP 192.168.1.104:6628 114.112.68.139:80 ESTABLISHED 2696
TCP 192.168.1.104:6665 220.181.164.53:80 ESTABLISHED 2696
TCP 192.168.1.104:6685 58.83.175.5:80 ESTABLISHED 2696
TCP 192.168.1.104:6721 117.34.15.39:80 ESTABLISHED 2696
TCP 192.168.1.104:6723 117.34.15.39:80 ESTABLISHED 2696
TCP 192.168.1.104:6739 58.83.175.71:80 ESTABLISHED 2696
TCP 192.168.1.104:6745 42.120.188.9:80 CLOSE_WAIT 6116
TCP 192.168.1.104:6746 220.181.113.250:80 TIME_WAIT 0
TCP 192.168.1.104:6747 220.181.113.250:80 ESTABLISHED 2520
TCP 192.168.1.104:6760 106.120.173.31:80 TIME_WAIT 0
TCP [::]:135 [::]:0 LISTENING 892
TCP [::]:445 [::]:0 LISTENING 4
TCP [::]:1025 [::]:0 LISTENING 568
TCP [::]:1026 [::]:0 LISTENING 996
TCP [::]:1027 [::]:0 LISTENING 368
TCP [::]:1028 [::]:0 LISTENING 632
TCP [::]:1029 [::]:0 LISTENING 692
TCP [::1]:27275 [::]:0 LISTENING 1292
UDP 0.0.0.0:500 *:* 368
UDP 0.0.0.0:3379 *:* 2696
UDP 0.0.0.0:4000 *:* 4600
UDP 0.0.0.0:4500 *:* 368
UDP 0.0.0.0:5355 *:* 1240
UDP 0.0.0.0:18386 *:* 6116
UDP 0.0.0.0:49152 *:* 1908
UDP 0.0.0.0:50171 *:* 1908
UDP 0.0.0.0:50172 *:* 3344
UDP 0.0.0.0:50173 *:* 632
UDP 0.0.0.0:50888 *:* 4600
UDP 0.0.0.0:52696 *:* 4600
UDP 0.0.0.0:54191 *:* 4600
UDP 0.0.0.0:56224 *:* 4600
UDP 0.0.0.0:56225 *:* 4600
UDP 0.0.0.0:56226 *:* 4600
UDP 0.0.0.0:58151 *:* 4600
UDP 0.0.0.0:58527 *:* 4112
UDP 0.0.0.0:59273 *:* 4600
UDP 0.0.0.0:62516 *:* 3048
UDP 0.0.0.0:64212 *:* 5748
UDP 0.0.0.0:64362 *:* 4600
UDP 127.0.0.1:1900 *:* 5016
UDP 127.0.0.1:60858 *:* 5444
UDP 127.0.0.1:64757 *:* 5016
UDP 169.254.156.64:137 *:* 4
UDP 169.254.156.64:138 *:* 4
UDP 169.254.156.64:1900 *:* 5016
UDP 192.168.1.104:68 *:* 996
UDP 192.168.1.104:137 *:* 4
UDP 192.168.1.104:138 *:* 4
UDP 192.168.1.104:1900 *:* 5016
UDP 192.168.1.104:64756 *:* 5016
UDP [::]:500 *:* 368
UDP [::]:4500 *:* 368
UDP [::]:5355 *:* 1240
UDP [::]:57582 *:* 1908
UDP [::1]:1900 *:* 5016
UDP [::1]:64755 *:* 5016
UDP [fe80::70ae:8c4a:3e55:9c40%16]:546 *:* 996
UDP [fe80::70ae:8c4a:3e55:9c40%16]:1900 *:* 5016
UDP [fe80::e517:7787:bf10:4679%12]:546 *:* 996
UDP [fe80::e517:7787:bf10:4679%12]:1900 *:* 5016
UDP [fe80::e517:7787:bf10:4679%12]:64754 *:* 5016
netsat -ano|findstr "135" 查找135端口是否被监听(常用于查看网站80或者FTP21端口是否监听)
C:\>netstat -ano|findstr "135"
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 892
TCP [::]:135 [::]:0 LISTENING 892
这里查到PID是892的这个程序监听135端口
tasklist |findstr "892" 查找PID892的程序名称是什么?
C:\>tasklist |findstr "892"
svchost.exe 892 Services 0 1,892 K
这里找到了该程序名字为svchost.exe,打开任务管理器,找到PID为892的程序
如果你的任务管理器不显示PID,按下图操作即可
查看---选择列