现在我们在对Netstat有了一定的了解之后就可以来使用它了,如果你打开了DOS窗口,你可以用以下命令来获取有关Netstat的帮助信息。
C:>netstat /?
-a Displays all connections and listening ports. (Server-side connections are normally not shown).
-e Displays Ethernet statistics. This 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 contents of 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 will print the
current configuration information once.
以上的信息仅仅是个参考,对于好奇心很强的您来说,是远远不够的。
那好,让我们试试每个命令并查看结果,用来理解当我们执行命令后发生了什么,显示出的信息是什么意思?
首先,我们使用Netstat的-a参数命令。
-a参数用来显示在本地机器上的外部连接,它也显示我们远程所连接的系统,本地和远程系统连接时使用的端口,和本地和远程系统连接的状态。(type and state)
例子:
C:>netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP ankit:1031 dwarfie.box.com:ftp ESTABLISHED
TCP ankit:1036 dwarfie.box.com:ftp-data TIME_WAIT
TCP ankit:1043 banners.egroups.com:80 FIN_WAIT_2
TCP ankit:1045 mail2.mtnl.net.in:pop3 TIME_WAIT
TCP ankit:1052 zztop.box.com:80 ESTABLISHED
TCP ankit:1053 mail2.mtnl.net.in:pop3 TIME_WAIT
UDP ankit:1025 *:*
UDP ankit:nbdatagram *:*