windows中的netstat命令

本文详细介绍Windows环境下Netstat命令的功能及参数使用方法,包括显示网络连接、协议统计信息、路由表等,帮助理解TCP/IP网络状况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


C:/>netstat /?

Displays protocol statistics and current TCP/IP network connections.

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]

  -a            Displays all connections and listening ports.
  -b            Displays the executable involved in creating each connection or
                listening port. In some cases well-known executables host
                multiple independent components, and in these cases the
                sequence of components involved in creating the connection
                or listening port is displayed. In this case the executable
                name is in [] at the bottom, on top is the component it called,
                and so forth until TCP/IP was reached. Note that this option
                can be time-consuming and will fail unless you have sufficient
                permissions.
  -e            Displays Ethernet statistics. This may be combined with the -s
                option.
  -n            Displays addresses and port numbers in numerical form.
  -o            Displays the owning process ID associated with each connection.
  -p proto      Shows connections for the protocol specified by proto; proto
                may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s
                option to display per-protocol statistics, proto may be any of:
                IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
  -r            Displays the routing table.
  -s            Displays per-protocol statistics.  By default, statistics are
                shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
                the -p option may be used to specify a subset of the default.
  -v            When used in conjunction with -b, will display sequence of
                components involved in creating the connection or listening
                port for all executables.
  interval      Redisplays selected statistics, pausing interval seconds
                between each display.  Press CTRL+C to stop redisplaying
                statistics.  If omitted, netstat will print the current
                configuration information once. 

如果你的计算机有时候接收到的数据报导致出错数据或故障,你不必感到奇怪,TCP/IP可以容许这些类型的错误,并能够自动重发数据报。但如果累计的出错 情况数目占到所接收的IP数据报相当大的百分比,或者它的数目正迅速增加,那么你就应该使用

Netstat查一查为什么会出现这些情况了。

Netstat 详细参数列表

(Winxp)

 

C:/>netstat /?

显示协议统计信息和当前 TCP/IP 网络连接。

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]

  -a  显示所有连接和监听端口。

  -b  显示包含于创建每个连接或监听端口的可执行组件。在某些情况下已知可执行组件

 拥有多个独立组件,并且在这些情况下包含于创建连接或监听端口的组件序列被显示。 这种情况下,可执行组件名在底部的 [] 中,顶部是其调用的组件,等等,直到TCP/IP部分。注意此选项可能需要很长时间,如果没有足够权限可能失败。

  -e            显示以太网统计信息。此选项可以与 -s 选项组合使用。

  -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          选项用于指定默认情况的子集。

  -v         与 -b 选项一起使用时将显示包含于为所有可执行组件创建连接或监听端口的组件。

 

  interval      重新显示选定统计信息,每次显示之间暂停时间间隔(以秒计)。按 CTRL+C 停止重新显示统计信息。如果省略,netstat 显示当前配置信息(只显示一次)


Netstat的一些常用选项

netstat -s ——本选项能够按照各个协议分别显示其统计数据。 如果你的应用程序(如Web浏览器)运行速度比较慢,或者不能显示Web页之类的数据,那么你就可以 用本选项来查看一下所显示的信息。你需要仔细查看统计数据的各行,找到出错的关键字,进而确定问题所在。

 

netstat -e ——本选项用于显示关于以太网的统计数据。 它列出的项目包括传送的数据报的总字节数、错误数、删除数、数据报的数量和广播的数量。这些统计数据既有发送的数据报数量,也有接收的数据报数量。这个选项可以用来统计一些基本的网络流量。


netstat -r ——本选项可以显示关于路由表的信息,类似于后面所讲使用route print命令时看到的信息。 除了显示有效路由外,还显示当前有效的连接。


netstat -a ——本选项显示一个所有的有效连接信息列表,包括已建立的连接(ESTABLISHED),也包括监听连接请求(LISTENING)的那些连接,断开连接(CLOSE_WAIT)或者处于联机等待状态的(TIME_WAIT)等


netstat -n ——显示所有已建立的有效连接

 

例子: from http://topic.youkuaiyun.com/t/20030811/09/2131381.html

 

具使用 提问 我机器是win2000pro,本地地址是192.168.0.192.在cmd下敲入命令:netstat   -an,结果如下:  
   
  Active   Connections  
   
      Proto     Local   Address                     Foreign   Address                 State  
      TCP         0.0.0.0:7                             0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:9                             0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:13                           0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:17                           0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:19                           0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:80                           0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:135                         0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:443                         0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:445                         0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:1025                       0.0.0.0:0                             LISTENING  
      TCP         0.0.0.0:1027                       0.0.0.0:0                             LISTENING  
      TCP         127.0.0.1:1033                   127.0.0.1:3306                   TIME_WAIT  
      TCP         127.0.0.1:1034                   127.0.0.1:3306                   TIME_WAIT  
      TCP         127.0.0.1:1035                   127.0.0.1:3306                   TIME_WAIT  
      TCP         127.0.0.1:1036                   127.0.0.1:3306                   TIME_WAIT  
      TCP         127.0.0.1:1037                   127.0.0.1:3306                   TIME_WAIT  
      TCP         192.168.0.192:139             0.0.0.0:0                             LISTENING  
      TCP         192.168.0.192:1030           192.168.0.167:139             TIME_WAIT  
      TCP         192.168.0.192:1054           192.168.0.167:139             TIME_WAIT  
      UDP         0.0.0.0:7                             *:*                                          
      UDP         0.0.0.0:9                             *:*                                          
      UDP         0.0.0.0:13                           *:*                                          
      UDP         0.0.0.0:17                           *:*                                          
      UDP         0.0.0.0:19                           *:*                                          
      UDP         0.0.0.0:135                         *:*                                          
      UDP         0.0.0.0:445                         *:*                                          
      UDP         0.0.0.0:1026                       *:*                                          
      UDP         0.0.0.0:3456                       *:*                                          
      UDP         192.168.0.192:137             *:*                                          
      UDP         192.168.0.192:138             *:*                                          
      UDP         192.168.0.192:500             *:*                                          
      UDP         192.168.0.192:520             *:*        
  ---------------------------------------------------------------------  
  问题:1.那个端口3306是什么?我查了半天也查不出来  
  2.LISTENING和TIME_WAIT以及ESTABLISHED个代表什么意思  
  3.ip为192.168.0.167是我一同事的机器,我们之间没有建立任何连接怎么也出现在上面的表里

 

回答:

 3306是mysql的端口  
  LISTENING——监听的  
  TIME_WAIT——等待的  
  ESTABLISHED——已经连接的  
   
  TCP         192.168.0.192:1030           192.168.0.167:139             TIME_WAIT  
  TCP         192.168.0.192:1054           192.168.0.167:139             TIME_WAIT  
  这两句的意思是192.168.0.192和192.168.0.167曾经有过连接,现在处于等待状态  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值