您的位置:首页 > 其它

netstat命令详解

2016-04-06 19:52 423 查看

参数详解

在windows下,netstat的命令行表达式如下:

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

在windows的CMD窗口运行
netstat /?
命令,就可以显示netstat的帮助信息:

参数作用
-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将打印当前的配置信息一次。
百度百科中的选项列表:

参数作用
-a显示所有socket,包括正在监听的。
-c每隔1秒就重新显示一遍,直到用户中断它。
-i显示所有网络接口的信息,格式
netstat -i
-n以网络IP地址代替名称,显示出网络连接情形。
-r显示核心路由表,格式同
route -e
-t显示TCP协议的连接情况
-u显示UDP协议的连接情况。
-v显示正在进行的工作。
-p显示建立相关连接的程序名和PID。
-b显示在创建每个连接或侦听端口时涉及的可执行程序。
-e显示以太网统计。此选项可以与
-s
选项结合使用。
-f显示外部地址的完全限定域名(FQDN)。
-o显示与每个连接相关的所属进程
-s显示每个协议的统计。
-x显示
NetworkDirect
连接、侦听器和共享端点。
-y显示所有连接的TCP连接模板。无法与其他选项结合使用。
interval重新显示选定的统计,各个显示间暂停的间隔秒数。按
CTRL+C
停止重新显示统计。如果省略,则
netstat
将打印当前的配置信息一次。
Wikipedia中关于netstat的选项列表:

参数作用
-aDisplays all active connections and the TCP and UDP ports on which the computer is listening.
-b (Windows)Displays the binary (executable) program’s name involved in creating each connection or listening port. (Windows XP, 2003 Server and newer Windows operating systems; not Microsoft Windows 2000 or older).
-b (OS X, NetBSD)Causes -i to report the total number of bytes of traffic.
-eDisplays ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s.
-f (Windows)Displays fully qualified domain names for foreign addresses (only available on Windows Vista and newer operating systems).
-f Address Family (FreeBSD)Limits display to a particular socket address family, unix, inet, inet6
-gDisplays multicast group membership information for both IPv4 and IPv6 (may only be available on newer operating systems)
-iDisplays network interfaces and their statistics (not available under Windows)
-mDisplays the memory statistics for the networking code (STREAMS statistics on Solaris).
-nDisplays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.
-o (Windows)Displays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a, -n, and -p. This parameter is available on Microsoft Windows XP, 2003 Server (and Windows 2000 if a hotfix is applied).[6]
-p protocol (Windows and BSD)Shows connections for the protocol specified by protocol. In this case, protocol can be tcp, udp, tcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6.
-p (Linux)Show which processes are using which sockets (similar to -b under Windows) (you must be root to do this)
-P protocol (Solaris)Shows connections for the protocol specified by protocol. In this case, protocol can be ip, ipv6, icmp, icmpv6, igmp, udp, tcp, or rawip.
-rDisplays the contents of the IP routing table. (This is equivalent to the route print command under Windows.)
-sDisplays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols.
-t (Linux)Display only TCP connections.
-W (FreeBSD)Display wide output - doesn’t truncate hostnames or IPv6 addresses
-v (Windows)When used in conjunction with -b it will display the sequence of components involved in creating the connection or listening port for all executables.
IntervalRedisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, netstat prints the selected information only once.
-h (unix)Displays help at the command prompt.
/? (windows)Displays help at the command prompt.

图解状态:





参考资料:

微软Netstat手册

Oracle:使用 netstat 命令监视网络状态

10 basic examples of linux netstat command

netstat 的10个基本用法(上一篇的中文版)

TIME_WAIT是什么?

解决TIME_WAIT过多问题

Linux netstat命令详解

linux netstat 命令详——查看端口使用情况

Netstat_百度百科
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  netstat