命令行大全

netstat

舞夕之 发表于 2020-06-28 11:00浏览次数:

Netstat命令用于显示TCP/IP网络协议统计信息。

查看英文版

目录:

1 netstat 运行系统环境

2 netstat 语法

3 netstat 示例

netstat 运行系统环境

Windows 95

Windows 98

Windows xp

Windows vista

Windows 2000

Windows 7

Windows 8

Windows 10

Windows NT

Windows ME

netstat 语法

Windows Vista和更高版本的语法
NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval]
-a 显示所有连接和侦听端口。
-b 显示创建每个连接或监听端口所涉及的可执行文件。在某些情况下,众所周知的可执行文件承载多个独立的组件,在这些情况下,会显示创建连接或侦听端口所涉及的组件序列。在本例中,可执行文件名称位于底部的[]中。 请注意,除非您有足够的权限,否则此选项可能很耗时并且会失败。
-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 显示routing表。
-s 显示每个协议的统计信息。默认情况下,将显示IP、IPv6、ICMP、ICMPv6、TCP、TCPv6、UDP和UDPv6的统计信息;-p选项可用于指定默认值的子集。
-t 显示当前连接卸载状态。
-x 显示NetworkDirect连接、侦听程序和共享端点。
-y 显示所有连接的TCP连接模板。不能与其他选项组合。
interval 重新显示选定的统计信息,并在每次显示之间暂停间隔秒。按Ctrl+C停止重新显示统计信息。如果省略,netstat将打印一次当前配置信息。
Windows XP和早期语法
NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]
-a 显示所有连接和侦听端口。
-e 显示以太网统计信息。此选项可与-s选项相结合。
-n 以数字形式显示地址和端口号。
-p proto 显示Proto指定的协议的连接;Proto可以是TCP或UDP。如果与-s选项一起使用以显示每个协议的统计信息,则proto可能是tcp, UDP,或IP。
-r 显示routing表。
-S 显示每个协议的统计信息。默认情况下,显示TCP、UDP和IP的统计信息;-p选项可用于指定默认值的子集。
interval 重新显示选定的统计信息,暂停每个显示之间的间隔秒。按Ctrl+C键停止重新显示统计信息。如果省略,netstat只打印一次当前配置信息。
Windows Vista and later syntax
NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [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. Note that this option can be time-consuming and fails unless you have sufficient permissions.
-e Displays Ethernet statistics. This option may be combined with the -s option.
-f Displays FQDN (fully qualified domain names) for foreign addresses.
-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.
-t Displays the current connection offload state.
-x Displays NetworkDirect connections, listeners, and shared endpoints.
-y Displays the TCP connection template for all connections. Cannot be combined with the other options.
interval Redisplays selected statistics, pausing interval seconds between each display. Press Ctrl+C to stop redisplaying statistics. If omitted, netstat prints the current configuration information once.
Windows XP and earlier syntax
NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]
-a Displays all connections and listening ports.
-e Displays Ethernet statistics. This option may be combined with the -s option.
-n Displays addresses and port numbers in numerical form.
-p proto Shows connections for the protocol specified by proto; proto may be TCP or UDP. If used with the -s option to display per-protocol statistics, proto may be TCP, UDP, or IP.
-r Displays the routing table.
-s Displays per-protocol statistics. By default, statistics are shown for TCP, UDP, and IP; the -p option may be used to specify a subset of the default.
interval Redisplays selected statistics, pausing interval seconds between each display. Press Ctrl+C to stop redisplaying statistics. If omitted, netstat prints the current configuration information once.

查看英文版

查看中文版

netstat 示例

netstat

显示所有本地网络信息。 下面是一个本地网络信息的示例。

Proto	Local Address	Foreign Address				State
TCP	hope:4409		www.computerhope.com:telnet	ESTABLISHED
TCP	hope:3708		multicity.com:80		CLOSE_WAIT
TCP	hope:4750		www.google.com:80		CLOSE_WAIT
netstat -an

以数字格式显示计算机上的所有连接,仅显示本地和外部IP地址。

netstat 5

在命令后运行带有编号的netstat将继续运行该命令,直到停止。在本例中,netstat将每5秒刷新一次。若要取消,请按Ctrl+C。

netstat

Displays all local network information. Below is an example of how this may look.

Proto	Local Address	Foreign Address				State
TCP	hope:4409		www.computerhope.com:telnet	ESTABLISHED
TCP	hope:3708		multicity.com:80		CLOSE_WAIT
TCP	hope:4750		www.google.com:80		CLOSE_WAIT
netstat -an

Displays all connections on the computers in numerical format, only displaying the local and foreign IP addresses.

netstat 5

Running netstat with a number after the command continues to run the command until stopped. In this case, netstat would be refreshed every five seconds. To cancel, press Ctrl+C.

如果您打开了网络应用程序,例如用于查看此页的Internet浏览器,则在运行“netstat”和“netstat-a”命令时会列出其他项目。如果您想要后台Internet连接的真实列表,请关闭所有程序并运行该命令。看到一个或多个0.0.0.0和127.0.0.1地址也是正常的。

If you have network applications open, such as the Internet browser you are using to view this page, additional items are listed when you run "netstat" and the "netstat -a" command. If you want a true listing of background Internet connections, close all programs and run the command. It is also normal to see one or more 0.0.0.0 and 127.0.0.1 addresses.

查看英文版

查看中文版