如果你的計算機有時候接收到的數據報導致出錯數據或故障,你不必感到奇怪,TCP/IP 可以容許這些類型的錯誤,並能夠自動重發數據報。但如果累計的出錯情況數目占到所接收的IP 數據報相當大的百分比,或者它的數目正迅速增加,那么你就應該使用Netstat 查一查為什么會出現這些情況了。
-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 顯示當前
配置信息( 只顯示一次)
-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 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 的一些常用選項
netstat -s ——本選項能夠按照各個協議分別顯示其統計數據。如果你的應用程序(如Web 瀏覽器)運行速度比較慢,或者不能顯示Web 頁之類的數據,那么你就可以用本選項來查看一下所顯示的信息。你需要仔細查看統計數據的各行,找到出錯的關鍵字,進而確定問題所在。
netstat -e ——本選項用於顯示關於以太網的統計數據。它列出的項目包括傳送的數據報的總字節數、錯誤數、刪除數、數據報的數量和廣播的數量。這些統計數據既有發送的數據報數量,也有接收的數據報數量。這個選項可以用來統計一些基本的網絡流量。
netstat -r ——本選項可以顯示關於路由表的信息,類似於后面所講使用route print 命令時看到的 信息。除了顯示有效路由外,還顯示當前有效的連接。
netstat -a ——本選項顯示一個所有的有效連接信息列表,包括已建立的連接(ESTABLISHED ),也包括監聽連接請求(LISTENING )的那些連接,斷開連接(CLOSE_WAIT )或者處於聯機等待狀態的(TIME_WAIT )等
netstat -n ——顯示所有已建立的有效連接。
TCP Eagle:ftp Eagle:0 LISTENING
TCP Eagle:telnet Eagle:0 LISTENING
TCP Eagle:smtp Eagle:0 LISTENING
TCP Eagle:http Eagle:0 LISTENING
TCP Eagle:epmap Eagle:0 LISTENING
TCP Eagle:https Eagle:0 LISTENING
TCP Eagle:microsoft-ds Eagle:0 LISTENING
TCP Eagle:1030 Eagle:0 LISTENING
TCP Eagle:6059 Eagle:0 LISTENING
TCP Eagle:8001 Eagle:0 LISTENING
TCP Eagle:8005 Eagle:0 LISTENING
TCP Eagle:8065 Eagle:0 LISTENING
TCP Eagle:microsoft-ds localhost:1031 ESTABLISHED
TCP Eagle:1031 localhost:microsoft-ds ESTABLISHED
TCP Eagle:1040 Eagle:0 LISTENING
TCP Eagle:netbios-ssn Eagle:0 LISTENING
TCP Eagle:1213 218.85.139.65:9002 CLOSE_WAIT
TCP Eagle:2416 219.133.63.142:https CLOSE_WAIT
TCP Eagle:2443 219.133.63.142:https CLOSE_WAIT
TCP Eagle:2907 192.168.1.101:2774 CLOSE_WAIT
TCP Eagle:2916 192.168.1.101:telnet ESTABLISHED
TCP Eagle:2927 219.137.227.10:4899 TIME_WAIT
TCP Eagle:2928 219.137.227.10:4899 TIME_WAIT
TCP Eagle:2929 219.137.227.10:4899 ESTABLISHED
TCP Eagle:3455 218.85.139.65:9002 ESTABLISHED
TCP Eagle:netbios-ssn Eagle:0 LISTENING
UDP Eagle:microsoft-ds *:*
UDP Eagle:1046 *:*
UDP Eagle:1050 *:*
UDP Eagle:1073 *:*
UDP Eagle:1938 *:*
UDP Eagle:2314 *:*
UDP Eagle:2399 *:*
UDP Eagle:2413 *:*
UDP Eagle:2904 *:*
UDP Eagle:2908 *:*
UDP Eagle:3456 *:*
UDP Eagle:4000 *:*
UDP Eagle:4001 *:*
UDP Eagle:6000 *:*
UDP Eagle:6001 *:*
UDP Eagle:6002 *:*
UDP Eagle:6003 *:*
UDP Eagle:6004 *:*
UDP Eagle:6005 *:*
UDP Eagle:6006 *:*
UDP Eagle:6007 *:*
UDP Eagle:6008 *:*
UDP Eagle:6009 *:*
UDP Eagle:6010 *:*
UDP Eagle:6011 *:*
UDP Eagle:1045 *:*
UDP Eagle:1051 *:*
UDP Eagle:netbios-ns *:*
UDP Eagle:netbios-dgm *:*
UDP Eagle:netbios-ns *:*
UDP Eagle:netbios-dgm *:*
本地機器名(Local Address ):Eagle ,俗稱計算機名了,安裝系統時設置的,可以在“我的電腦”屬性中修改,本地打開並用於連接的端口:2929 )
遠程機器名(Foreign Address ): 219.137.227.10
遠程端口: 4899
狀態:ESTABLISHED
ESTABLISHED :已建立聯機的聯機情況。
TIME_WAIT :該聯機在目前已經是等待的狀態。
Port 12345(TCP) Netbus
Port 31337(UDP) Back Orifice
祝賀! 您中了最常見的木馬(^_^ ,上面4899 是我連別人的,而且這個radmin 是商業軟件,目前我最喜歡的遠程控制軟件)
如果你需要木馬及其端口列表的話,去國內的H 站找找,或者baidu ,google 吧
*****************************************************************
# 一些原理:也許你有這樣的問題:“在機器名后的端口號代表什么?
例子: Eagle:2929
小於1024 的端口通常運行一些網絡服務,大於1024 的端口用來與遠程機器建立連接。
*****************************************************************
Netstat -n 基本上是-a 參數的數字形式:
TCP 127.0.0.1:445 127.0.0.1:1031 ESTABLISHED
TCP 127.0.0.1:1031 127.0.0.1:445 ESTABLISHED
TCP 192.168.1.180:1213 218.85.139.65:9002 CLOSE_WAIT
TCP 192.168.1.180:2416 219.133.63.142:443 CLOSE_WAIT
TCP 192.168.1.180:2443 219.133.63.142:443 CLOSE_WAIT
TCP 192.168.1.180:2907 192.168.1.101:2774 CLOSE_WAIT
TCP 192.168.1.180:2916 192.168.1.101:23 ESTABLISHED
TCP 192.168.1.180:2929 219.137.227.10:4899 ESTABLISHED
TCP 192.168.1.180:3048 192.168.1.1:8004 SYN_SENT
TCP 192.168.1.180:3455 218.85.139.65:9002 ESTABLISHED
TCP Eagle:microsoft-ds localhost:1031 ESTABLISHED
TCP Eagle:1031 localhost:microsoft-ds ESTABLISHED
TCP Eagle:1213 218.85.139.65:9002 CLOSE_WAIT
TCP Eagle:2416 219.133.63.142:https CLOSE_WAIT
TCP Eagle:2443 219.133.63.142:https CLOSE_WAIT
TCP Eagle:2907 192.168.1.101:2774 CLOSE_WAIT
TCP Eagle:2916 192.168.1.101:telnet ESTABLISHED
TCP Eagle:2929 219.137.227.10:4899 ESTABLISHED
TCP Eagle:3455 218.85.139.65:9002 ESTABLISHED
Interface Statistics
Unicast packets 691805 363603
Non-unicast packets 886526 2386
Discards 0 0
Errors 0 0
Unknown protocols 4449
===========================================================================
Interface List (網絡接口列表)
0x1 ........................... MS TCP Loopback interface
0x10003 ...00 0c f1 02 76 81 ...... Intel(R) PRO/Wireless LAN 2100 3B Mini PCI
dapter
0x10004 ...00 02 3f 00 05 cb ...... Realtek RTL8139/810x Family Fast Ethernet
C
===========================================================================
===========================================================================
Active Routes: (動態路由)
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.254 192.168.1.181 30
0.0.0.0 0.0.0.0 192.168.1.254 192.168.1.180 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.1.0 255.255.255.0 192.168.1.180 192.168.1.180 20
192.168.1.0 255.255.255.0 192.168.1.181 192.168.1.181 30
192.168.1.180 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.1.181 255.255.255.255 127.0.0.1 127.0.0.1 30
192.168.1.255 255.255.255.255 192.168.1.180 192.168.1.180 20
192.168.1.255 255.255.255.255 192.168.1.181 192.168.1.181 30
224.0.0.0 240.0.0.0 192.168.1.180 192.168.1.180 20
224.0.0.0 240.0.0.0 192.168.1.181 192.168.1.181 30
255.255.255.255 255.255.255.255 192.168.1.180 192.168.1.180 1
255.255.255.255 255.255.255.255 192.168.1.181 192.168.1.181 1
Default Gateway: 192.168.1.254 (默認網關)
===========================================================================
Persistent Routes: (靜態路由)
None
Received Header Errors = 0 (接收頭錯誤數)
Received Address Errors = 2 (接收地址錯誤數)
Datagrams Forwarded = 0 (數據報遞送數)
Unknown Protocols Received = 0 (未知協議接收數)
Received Packets Discarded = 4203 (接收后丟棄的包數)
Received Packets Delivered = 365287 (接收后轉交的包數)
Output Requests = 369066 (請求數)
Routing Discards = 0 (路由丟棄數 )
Discarded Output Packets = 2172 (包丟棄數)
Output Packet No Route = 0 (不路由的請求包)
Reassembly Required = 0 (重組的請求數 )
Reassembly Successful = 0 (重組成功數)
Reassembly Failures = 0 (重組失敗數)
Datagrams Successfully Fragmented = 0 (分片成功的數據報數 )
Datagrams Failing Fragmentation = 0 (分片失敗的數據報數 )
Fragments Created = 0 (分片建立數)
Messages 285 784 (消息數 )
Errors 0 0 (錯誤數)
Destination Unreachable 53 548 (無法到達主機數目)
Time Exceeded 0 0 (超時數目)
Parameter Problems 0 0 (參數錯誤)
Source Quenches 0 0 (源夭折數 )
Redirects 0 0 (重定向數)
Echos 25 211 (回應數)
Echo Replies 207 25 (回復回應數)
Timestamps 0 0 (時間戳數)
Timestamp Replies 0 0 (時間戳回復數)
Address Masks 0 0 (地址掩碼數 )
Address Mask Replies 0 0 (地址掩碼回復數)
Passive Opens = 80 (被動打開數 )
Failed Connection Attempts = 2944 (連接失敗嘗試數 )
Reset Connections = 529 (復位連接數 )
Current Connections = 9 (當前連接數目)
Segments Received = 350143 (當前已接收的報文數)
Segments Sent = 347561 (當前已發送的報文數)
Segments Retransmitted = 6108 (被重傳的報文數目)
No Ports = 1360 (無端口數)
Receive Errors = 0 (接收錯誤數)
Datagrams Sent = 14524 (數據包發送數)
分類: Windows平台
linux下有wc做命令管道輸出結果行數,windows下沒有wc命令,但可以通過find命令做統計。
find命令需匹配字符串后統計,find命令參數如下:
C:\Users\l00207432>find /?
在文件中搜索字符串。
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]
/V 顯示所有未包含指定字符串的行。
/C 僅顯示包含字符串的行數。
/N 顯示行號。
/I 搜索字符串時忽略大小寫。
/OFF[LINE] 不要跳過具有脫機屬性集的文件。
"string" 指定要搜索的文本字符串。
[drive:][path]filename
指定要搜索的文件。
如果沒有指定路徑,FIND 將搜索在提示符處鍵入
的文本或者由另一命令產生的文本。
如搜索當前網絡TCP連接數:
c:\>netstat -na | find /C "TCP"
63
加 I 參數忽略大小寫:
C:\>netstat -na | find /C /I "Tcp"
63
但如果我們要統計全部網絡連接數,包括tcp、udp等,這個怎么處理呢?這時我們可以做個逆向搜索,參數 V 顯示所有未包含指定字符串的行,這個我們可以構造一個不可能在命令輸出結果里出現的字符串來反向輸出需要的結果,如需要顯示當前全部網絡連接數:
C:\>netstat -na | find /C /I /V "string not exists"
107
輸出結果是107行,也就是當前網絡連接數是107,比只是顯示tcp的明顯多了。