netstat(8) - Linux man page(中文翻譯)
名稱
netstat - 輸出網絡連接, 路由表, 接口統計數據, 僞連接,及多播成員
大綱
netstat [address_family_options] [--tcp|-t] [--udp|-u] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--symbolic|-N] [--extend|-e[--extend|-e]] [--timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c] [delay]
netstat {--route|-r} [address_family_options] [--extend|-e[--extend|-e]] [--verbose|-v] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
netstat {--interfaces|-i} [iface] [--all|-a] [--extend|-e[--extend|-e]] [--verbose|-v] [--program|-p] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
netstat {--groups|-g} [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
netstat {--masquerade|-M} [--extend|-e] [--numeric|-n] [--numeric-hosts][--numeric-ports][--numeric-ports] [--continuous|-c] [delay]
netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--raw|-w] [delay]
netstat {--version|-V}
netstat {--help|-h}
address_family_options:
[--protocol={inet,unix,ipx,ax25,netrom,ddp}[,...]] [--unix|-x] [--inet|--ip] [--ax25] [--ipx] [--netrom] [--ddp]
描述
Netstat 命令輸出linux網絡子系統的信息。 輸出的信息類型由其後的第一個參數決定,如下:
(none)
默認情況下,該命令顯示系統打開的socket列表。如果沒有給定特定的地址族,那麼所有被配置的地址族的活動socket信息會被全部打印出來。
--route , -r
顯示內核路由表。
--groups , -g
顯示IPV4及IPV6的多播組成員信息。
--interface=iface , -i
顯示網絡接口表或者某個特定的接口信息。
--masquerade , -M
顯示僞連接列表。
--statistics , -s
顯示每個協議的概要統計數據。
選項
--verbose , -v
輸出儘可能多的信息,其中包括一些未被配置的地址族信息。
--numeric , -n
輸出數字化的IP地址,而非主機名或用戶名。
--numeric-hosts
輸出數字化的主機地址,而不影響端口名和用戶名的解析。
--numeric-ports
輸出數字化的端口號,而不影響主機名和用戶名的解析。.
--numeric-users
輸出數字化的用戶ID,而不影響主機名和端口名的解析。
--protocol=family , -A
指定將要輸出的地址族。 家族用逗號隔開,例如: inet, unix, ipx, ax25, netrom, ddp。
這和適用以下這種指定家族的方式相同: --inet, --unix (-x), --ipx, --ax25, --netrom, and --ddp options.
inet 家族包括 raw, udp 和 tcp 協議 sockets.
-c, --continuous
這會使得該命令持續輸出網絡狀態,每隔一小段時間就重新輸出。
-e, --extend
顯示額外信息,連用兩個可以顯示最多的信息。
-o, --timers
包含網絡計時器相關的信息。
-p, --program
顯示 socket 所歸屬的 PID 以及程序名。
-l, --listening
只顯示處於監聽狀態的socket。
-a, --all
顯示所有處於監聽或非監聽狀態的socket。 在用 --interfaces 指定端口的情況下, 同樣會顯示非指定的端口信息。
-f
從 FIB 打印路由信息。
-c
從路由緩衝區打印路由信息。
-Z --context
如果 SELinux 允許輸出 SELinux 上下文。
-T --notrim
停止整理長地址。
delay
該命令會每隔 delay 長的時間循環打印所有數據。
輸出
活動的網絡連接 (TCP, UDP, raw)
Proto
socket 所適用的協議 (tcp, udp, raw) 。
Recv-Q
未被連接到 socket 的用戶程序所複製的字節數。
Send-Q
未被遠程主機確認的字節數。
Local Address
socket 本地端的地址及端口號。除非 --numeric (-n) 選項被指定, 否則 socket 地址會被解析成其權威的主機名 (FQDN), 同時端口號被翻譯成通信服務名。
Foreign Address
socket 遠程端的地址及端口號。相對於本地地址而言的。
State
socket 的狀態。由於在 raw 模式下無狀態,同時在 udp 模式下一般也無狀態, 所以該欄在大多情況下都是空白的。通常狀態值可以爲以下幾種:
- ESTABLISHED
- socket 擁有已建立的連接。
- SYN_SENT
- socket 正在嘗試建立連接。
- SYN_RECV
- 已從網絡獲得一個連接請求。
- FIN_WAIT1
- socket 被關閉, 連接被停止。
- FIN_WAIT2
- 連接被關閉, socket 在等待遠端關閉。
- TIME_WAIT
- socket 被關閉後仍在等待, 以處理仍然存在在網絡中的包。
- CLOSED
- socket 未被使用。
- CLOSE_WAIT
- 遠端已關閉, 在等待 socket 的關閉。
- LAST_ACK
- 遠端及 socket 都已關閉, 等待最後的確認。
- LISTEN
- socket 正在監聽傳入的連接。這些 socket 不會被輸出, 除非使用了 -l 或 -a 選項。
- CLOSING
- 兩端的 socket 都已關閉, 但是仍未將本端數據傳輸完畢。
- UNKNOWN
- socket 狀態未知。
User
socket 擁有者的用戶名或用戶ID。
PID/Program name
擁有 socket 的進程的進程ID及進程名, 用斜槓分割。 --program 使得這一欄被包含進來。你需要超級用戶的權限纔可以看到非你所擁有的進程的 socket 信息。IPX socket 無此項。
Timer
(this needs to be written)
活動的Unix域名Socket
Proto
socket 使用的協議。
RefCnt
引用計數。
Flags
顯示的標誌是:SO_ACCEPTON (displayed as ACC), SO_WAITDATA (W) 或者 SO_NOSPACE (N). SO_ACCECPTON 用於正等待連接請求的未連接 socket。
Type
下列幾種 socket 使用權:
- SOCK_DGRAM
- The socket is used in Datagram (connectionless) mode.
- SOCK_STREAM
- This is a stream (connection) socket.
- SOCK_RAW
- The socket is used as a raw socket.
- SOCK_RDM
- This one serves reliably-delivered messages.
- SOCK_SEQPACKET
- This is a sequential packet socket.
- SOCK_PACKET
- Raw interface access socket.
- UNKNOWN
- Who ever knows what the future will bring us - just fill in here :-)
State
這個域會包括以下幾種之一的關鍵詞:
- FREE
- The socket is not allocated
- LISTENING
- The socket is listening for a connection request. Such sockets are only included in the output if you specify the --listening (-l) or --all (-a) option.
- CONNECTING
- The socket is about to establish a connection.
- CONNECTED
- The socket is connected.
- DISCONNECTING
- The socket is disconnecting.
- (empty)
- The socket is not connected to another one.
- UNKNOWN
- This state should never happen.
PID/Program name
開啓 socket 的PID和進程名。更多的信息在 Active Internet connections 部分。
Path
This is the path name as which the corresponding processes attached to the socket.
Active IPX sockets
(this needs to be done by somebody who knows it)
Active NET/ROM sockets
(this needs to be done by somebody who knows it)
Active AX.25 sockets
(this needs to be done by somebody who knows it)
Notes
Starting with Linux release 2.2 netstat -i does not show interface statistics for alias interfaces. To get per alias interface counters you need to setup explicit rules using the ipchains(8) command.
Files
/etc/services -- The services translation
file
/proc -- Mount point for the proc filesystem, which gives access to kernel status information via the following files.
/proc/net/dev -- device
information
/proc/net/raw -- raw socket information
/proc/net/tcp -- TCP
socket information
/proc/net/udp -- UDP socket information
/proc/net/igmp -- IGMP multicast information
/proc/net/unix -- Unix domain socket information
/proc/net/ipx -- IPX socket information
/proc/net/ax25 -- AX25 socket information
/proc/net/appletalk -- DDP (appletalk) socket information
/proc/net/nr -- NET/ROM socket information
/proc/net/route -- IP routing information
/proc/net/ax25_route -- AX25 routing information
/proc/net/ipx_route -- IPX routing information
/proc/net/nr_nodes -- NET/ROM nodelist
/proc/net/nr_neigh -- NET/ROM neighbours
/proc/net/ip_masquerade -- masqueraded connections
/proc/net/snmp -- statistics
See Also
route(8), ifconfig(8), ipchains(8), iptables(8), proc(5)
Bugs
Occasionally strange information may appear if a socket changes as it is viewed. This is unlikely to occur.
Authors
The netstat user interface was written by Fred Baumgarten <[email protected]> the man page basically by Matt Welsh <[email protected]>. It was updated by Alan Cox <[email protected]> but could do with a bit more work. It was updated again by Tuan Hoang <[email protected]>.
The man page and the command included in the net-tools package is totally rewritten by Bernd Eckenfels <[email protected]>.
Referenced By
arp(8), icmp(7), ifinfo(8), inndstart(8), ipsec_look(8), netmask(1), socklist(8), traceroute(8)