简介
本文介绍Windows的netstat命令的用法。
参数
netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p <proto>] [-q] [-r] [-s] [-t] [-x] [-y] [interval]
结果含义
状态
"LISTENING":表示监听。即:这个端口正在开放 可以提供服务
"CLOSING":表示关闭的。即:表示端口人为或者防火墙使其关闭(也许服务被卸载)
"TIME WAIT":表示正在等待连接。即:你正在向该端口发送请求连接状态
"ESTABLISHED":表示是对方与你已经连接。即:正在通信交换数据
示例
例1:查看所有端口使用情况
命令
netstat -ano
结果
C:\Users\xxx>netstat -nao
活动连接
协议 本地地址 外部地址 状态 PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 808
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 4668
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 4512
TCP 0.0.0.0:912 0.0.0.0:0 LISTENING 4512
TCP 0.0.0.0:5040 0.0.0.0:0 LISTENING 3564
TCP 0.0.0.0:5357 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:6300 0.0.0.0:0 LISTENING 3972
TCP 0.0.0.0:6666 0.0.0.0:0 LISTENING 1188
TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING 888
TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING 764
TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING 1516
TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING 1788
TCP 0.0.0.0:49668 0.0.0.0:0 LISTENING 2508
TCP 0.0.0.0:49671 0.0.0.0:0 LISTENING 3764
TCP 0.0.0.0:49698 0.0.0.0:0 LISTENING 840
TCP 127.0.0.1:1001 0.0.0.0:0 LISTENING 4
TCP 127.0.0.1:8307 0.0.0.0:0 LISTENING 4668
TCP 127.0.0.1:14147 0.0.0.0:0 LISTENING 3972
TCP 127.0.0.1:48303 0.0.0.0:0 LISTENING 4420
TCP 127.0.0.1:48303 127.0.0.1:49713 ESTABLISHED 4420
TCP 127.0.0.1:49713 127.0.0.1:48303 ESTABLISHED 4420
TCP 127.0.0.1:49799 0.0.0.0:0 LISTENING 1736
TCP 127.0.0.1:49799 127.0.0.1:49831 ESTABLISHED 1736
TCP 127.0.0.1:49831 127.0.0.1:49799 ESTABLISHED 8716
TCP 127.0.0.1:59866 0.0.0.0:0 LISTENING 11428
TCP 192.168.0.98:139 0.0.0.0:0 LISTENING 4
TCP 192.168.0.98:6666 91.241.19.228:54404 ESTABLISHED 1188
TCP 192.168.0.98:6666 195.54.167.7:60042 ESTABLISHED 1188
TCP 192.168.0.98:49839 61.147.223.240:80 CLOSE_WAIT 13732
TCP 192.168.0.98:59568 117.80.92.109:6667 ESTABLISHED 13136
TCP 192.168.0.98:59882 104.27.129.182:80 TIME_WAIT 0
TCP 192.168.0.98:59897 180.101.49.12:443 ESTABLISHED 14156
TCP 192.168.0.98:59905 101.200.35.175:443 ESTABLISHED 14156
TCP 192.168.0.98:59914 39.96.132.69:443 ESTABLISHED 14156
TCP 192.168.0.98:59926 101.201.173.208:443 ESTABLISHED 14156
TCP 192.168.0.98:59930 101.201.173.208:443 ESTABLISHED 14156
TCP 192.168.0.98:59931 39.96.132.69:443 ESTABLISHED 14156
TCP 192.168.0.98:59934 39.96.132.69:443 ESTABLISHED 14156
TCP 192.168.0.98:59950 140.143.49.61:443 ESTABLISHED 14156
TCP 192.168.0.98:59951 40.90.189.152:443 ESTABLISHED 14156
TCP 192.168.0.98:59952 40.90.189.152:443 ESTABLISHED 14156
TCP 192.168.0.98:59958 180.97.232.87:443 ESTABLISHED 14156
TCP 192.168.0.98:59970 203.119.169.83:443 ESTABLISHED 14156
TCP 192.168.0.98:59971 194.156.231.202:8443 ESTABLISHED 8716
TCP 192.168.0.98:59998 61.155.222.97:443 ESTABLISHED 14156
TCP 192.168.0.98:60016 183.134.25.125:443 ESTABLISHED 14156
TCP 192.168.0.98:60080 39.97.4.86:443 ESTABLISHED 14156
TCP 192.168.0.98:60097 101.201.171.59:443 ESTABLISHED 14156
TCP 192.168.0.98:60106 69.94.69.166:443 ESTABLISHED 14156
TCP 192.168.0.98:60107 69.94.69.166:443 TIME_WAIT 0
TCP 192.168.0.98:60117 180.122.76.243:443 ESTABLISHED 14156
TCP 192.168.0.98:60118 52.114.132.91:443 ESTABLISHED 11236
TCP 192.168.0.98:60119 222.186.55.14:443 ESTABLISHED 14156
例2:查看指定端口
命令
netstat -nao | findstr "端口号"
结果
C:\Users\xxx>netstat -ano | findstr "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 50388
TCP 10.0.10.80:58629 157.255.245.177:8080 ESTABLISHED 12596
TCP 10.0.10.80:62828 58.251.100.119:8080 ESTABLISHED 49072
TCP 10.0.10.80:65521 116.130.229.191:8080 ESTABLISHED 11692
TCP [::]:8080 [::]:0 LISTENING 50388