netstat 顯示網路連線、路由表 (-r)、介面 (-i)、偽裝連線 (-M)、多重廣播成員 (-g) 以及統計資料 (-s)。
tester@linux:~> netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.22.0 * 255.255.254.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.22.254 0.0.0.0 UG 0 0 0 eth0
tester@linux:~> netstat -i Kernel Interface table Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1500 0 1624507 129056 0 0 7055 0 0 0 BMNRU lo 16436 0 23728 0 0 0 23728 0 0 0 LRU
顯示網路連接或數據時,您可指定要顯示的插槽類型:TCP (-t)、UDP (-u)netstat,或 raw (-r)。-p 選項顯示 PID 和每個插槽所屬的程式名稱。
下例列出所有 TCP 連線和使用這些連線的程式。
linux:~ # netstat -t -p Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Pro tcp 0 0 linux:33513 www.novell.com:www-http ESTABLISHED 6862/fi tcp 0 352 linux:ssh linux2.:trc-netpoll ESTABLISHED 19422/s tcp 0 0 localhost:ssh localhost:17828 ESTABLISHED -
以下會顯示 TCP 通訊協定的統計資料:
tester@linux:~> netstat -s -t
Tcp:
2427 active connections openings
2374 passive connection openings
0 failed connection attempts
0 connection resets received
1 connections established
27476 segments received
26786 segments send out
54 segments retransmited
0 bad segments received.
6 resets sent
[...]
TCPAbortOnLinger: 0
TCPAbortFailed: 0
TCPMemoryPressures: 0