NETSTAT(8) Linux Programmer’s Manual NETSTAT(8)
名前
netstat - ネットワーク接続、経路テーブル、インターフェースの状態、マス
カレード接続、 netlink メッセージ、マルチキャストのメンバーシップを表示
する
書式
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]
netstat {--route|-r} [address_family_options]
[--extend|-e[--extend|-e]] [--verbose|-v] [--numeric|-n] [--numeric-
hosts][--numeric-ports][--numeric-ports] [--continuous|-c]
netstat {--interfaces|-i} [iface] [--all|-a] [--extend|-e[--extend|-e]]
[--verbose|-v] [--program|-p] [--numeric|-n] [--numeric-
hosts][--numeric-ports][--numeric-ports] [--continuous|-c]
netstat {--groups|-g} [--numeric|-n] [--numeric-hosts][--numeric-
ports][--numeric-ports] [--continuous|-c]
netstat {--masquerade|-M} [--extend|-e] [--numeric|-n] [--numeric-
hosts][--numeric-ports][--numeric-ports] [--continuous|-c]
netstat {--statistics|-s} [--tcp|-t] [--udp|-u] [--raw|-w]
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 のネットワークシステムに関する情報を表示する。表示され
る情報のタイプは、最初の引き数で以下のように制御される。
(引き数なし)
デフォルトでは、 netstat はオープンされているソケットの一覧を表示する。
ア ドレスファミリーが指定されていなければ、設定されている全てのアドレス
ファミリーに関して、アクティブなソケットが表示される。
--route , -r
カーネルの経路テーブルを表示する。
--groups , -g
IPv4 と IPv6 のマルチキャストグループメンバーシップ情報を表示する。
--interface=iface , -i
全ての (あるいは iface で指定した) ネットワークインターフェースの状態テ
ーブルを表示する。
--masquerade , -M
マスカレードされた接続を表示する。
--statistics , -s
各プロトコルの統計情報の一覧を表示する。
オプション
--verbose , -v
詳 細表示モードになり、起こっていることをユーザーに知らせる。特に、設定
されていないアドレスファミリー関する有用な情報をいくつか表示する。
--numeric , -n
ホスト・ポート・ユーザーなどの名前を解決せずに、数字のアドレスで表示 す
る。
--numeric-hosts
ホ ストアドレスを数値で表示する。ただし、ポート名とユーザー名の解決は行
う。
--numeric-ports
ポート番号を数値で表示する。ただし、ホスト名とユーザー名の解決は行う。
--numeric-users
ユーザー ID を数値で表示する。ただし、ホスト名とポート名の解決は行う。
--protocol=family , -A
接続状態を表示するアドレスファミリーを指定する (低レベルのプロトコル を
指定すれば、アドレスファミリーをうまく記述できるだろう)。 family はコン
マ (’,’) で区切られたリストで、アドレスファミリーのキーワードを指定する
。 キーワードとして inet, unix, ipx, ax25, netrom, ddp が指定できる。こ
れは、 --inet, --unix (-x), --ipx, --ax25, --netrom, --ddp オプションを
使った場合と同じ効果がある。
アドレスファミリー inet には raw, udp, tcp プロトコルソケットが含まれる
。
-c, --continuous
指定された情報を 1 秒ごとに表示し続ける。
-e, --extend
さらに詳しい情報を表示する。このオプションを 2 個指定すれば最も詳しい表
示が得られる。
-o, --timers
ネットワーキングタイマーに関する情報が追加される。
-p, --program
各ソケットが属しているプログラムの PID と名前が表示される。
-l, --listening
接 続待ち (listen) 状態にあるソケットのみを表示する (このオプションはデ
フォルトでは省略される)。
-a, --all
接続待ち状態にあるソケットも、接続待ち状態にないソケットも表示 す る 。
--interfaces オプションが指定された場合、マークされていないインターフェ
ースを表示する。
-F
FIB からの経路情報を表示する (これはデフォルトである)。
-C
経路キャッシュからの経路情報を表示する。
出力
アクティブなインターネット接続 (TCP, UDP, raw)
Proto
ソケットで用いられているプロトコル (tcp, udp, raw のいずれか)。
Recv-Q
このソケットに接続されたユーザープログラムに渡されなかったデータのバ イ
ト数。
Send-Q
リモートホストに受け入れられなかったデータのバイト数。
Local Address
ロ ーカル側ソケットのアドレスとポート番号。 --numeric (-n) オプションが
指定されない限り、ソケットアドレスは正式なホスト名 (FQDN) になり、ポ ー
ト番号は対応するサービス名に変換される。
Foreign Address
リモート側ソケットのアドレスとポート番号。その他は "Local Address" と同
様である。
State
ソケットの状態 (state)。 raw モードには状態がなく、また UDP も通常状 態
を使用しないため、この項目は空白になっている。普通は以下の値のどれか:
ESTABLISHED
ソケットは確立した接続状態にある。
SYN_SENT
ソケットは接続を確立しようと試みている。
SYN_RECV
接続要求をネットワークから受信している。
FIN_WAIT1
ソケットはクローズされており、接続は切断中である。
FIN_WAIT2
接続はクローズされ、ソケットはリモート側からの切断を待っている。
TIME_WAIT
ソケットは、クローズ後にリモートからの切断が再送されるのを待って
いる。
CLOSED ソケットは使用されていない。
CLOSE_WAIT
リモート側は既に切断され、ソケットがクローズされるのを待っている
。
LAST_ACK
リモート側は既に切断され、ソケットもクローズされてい る 。 確 認
(acknowledgement) を待っている。
LISTEN ソ ケ ッ ト は 接続待ち (listen) である。このようなソケットは、
--listening (-l) または --all (-a) オプションを指定しない限り 、
出力には含まれない。
CLOSING
両方のソケットが切断されているが、まだ全てのデータが送られていな
い。
UNKNOWN
ソケットの状態は不明である。
User
ソケットのオーナーの、名前またはユーザー ID (UID)。
PID/Program name
このソケットを所有しているプログラムのプロセス ID (PID) とプログラム 名
の 対 (スラッシュで区切られる)。 --program オプションによってこの項目が
現れる。自分が所有していないソケットの情報を見るためには、 スーパーユー
ザー特権が必要である。この識別情報は IPX ソケットに対してはまだ利用でき
ない。
Timer
(まだ書いていない)
アクティブな UNIX ドメインソケット
Proto
ソケットで用いられているプロトコル (通常は unix)。
RefCnt
参照カウント (このソケットに接続されているプロセス数)。
Flags
表示されるフラグは SO_ACCEPTON (ACC と表示される)、 SO_WAITDATA (W) 、
SO_NOSPACE (N) である。 SO_ACCEPTON は、ソケットが接続されておらず、か
つそれを用いているプログラムが接続要求を待っている場合に用いられる。 他
のフラグは通常は重要ではない。
Type
ソケットアクセスのタイプ。何種類かある:
SOCK_DGRAM
データグラム (connectionless) モードのソケットである。
SOCK_STREAM
ストリーム (connection) ソケットである。
SOCK_RAW
raw ソケットである。
SOCK_RDM
信頼性の高いメッセージを届けるソケットである。
SOCK_SEQPACKET
シーケンシャルパケットのソケットである。
SOCK_PACKET
raw インターフェースアクセスのソケットである。
UNKNOWN
将来なにが起こるか誰が知ろうか - ここに書いて下さい :-)
State
このフィールドには、以下のキーワードのいずれかが入る:
FREE ソケットは割り当てられていない。
LISTENING
ソ ケットは接続要求の待ち状態である。これらのソケットは、 --lis-
tening (-l) または --all (-a) オプションが指定されない限り、出力
されない。
CONNECTING
ソケットは接続中である。
CONNECTED
ソケットは接続されている。
DISCONNECTING
ソケットは切断中である。
(空白) ソケットは他のソケットに接続されていない。
UNKNOWN
このステートは現われないはずである。
PID/Program name
こ のソケットをオープンしているプログラムのプロセス ID (PID) とプロセス
名。より詳しい情報は上記の アクティブなインターネット接続の項を参照のこ
と。
Path
ソケットに結び付けられているプロセスのパス名。
アクティブな IPX ソケット
(知識を持っている人が記述してほしい)
アクティブな NET/ROM ソケット
(知識を持っている人が記述してほしい)
アクティブな AX.25 ソケット
(知識を持っている人が記述してほしい)
注意
カーネルリリース 2.2 から、 netstat -i では別名インターフェースのインタ
ーフェース統計を表示しなくなった。別名インターフェース毎の統計を得る た
めには、 ipchains(8) コマンドを用いて明示的にルールを設定する必要がある
。
ファイル
/etc/services -- サービス名と番号の変換表が入ったファイル
/proc -- proc ファイルシステムのマウントポイント。このファイルシステ ム
により、以下のファイルを使ってカーネルの統計情報にアクセスできる。
/proc/net/dev -- デバイスの情報
/proc/net/raw raw ソケットの情報
/proc/net/tcp -- TCP ソケットの情報
/proc/net/udp -- UDP ソケットの情報
/proc/net/igmp -- IGMP マルチキャストの情報
/proc/net/unix -- Unix ドメインソケットの情報
/proc/net/ipx -- IPX ソケットの情報
/proc/net/ax25 -- AX25 ソケットの情報
/proc/net/appletalk -- DDP (appletalk) ソケットの情報
/proc/net/nr -- NET/ROM ソケットの情報
/proc/net/route -- IP 経路情報
/proc/net/ax25_route -- AX25 経路情報
/proc/net/ipx_route -- IPX 経路情報
/proc/net/nr_nodes -- NET/ROM ノードリスト
/proc/net/nr_neigh -- NET/ROM ネイバー (neighbour)
/proc/net/ip_masquerade -- マスカレード接続
/proc/net/snmp -- 統計情報
関連項目
route(8), ifconfig(8), ipchains(8), iptables(8), proc(5)
バグ
ソ ケットが表示中に変更されると、たまに妙な情報が表示されることがある。
あまり起こらないとは思うが。
著者
netstat の ユ ー ザ ー イ ン タ ー フ ェ ー ス は Fred Baumgarten
NETSTAT(8) Linux Programmer’s Manual NETSTAT(8)
NAME
netstat - Print network connections, routing tables, interface statis-
tics, masquerade connections, and multicast memberships
SYNOPSIS
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|-i} [iface] [--all|-a] [--extend|-e] [--ver-
bose|-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,inet6,unix,ipx,ax25,netrom,ddp, ... } ] [--unix|-x]
[--inet|--ip] [--ax25] [--ipx] [--netrom] [--ddp]
NOTE
This program is obsolete. Replacement for netstat is ss. Replacement
for netstat -r is ip route. Replacement for netstat -i is ip -s link.
Replacement for netstat -g is ip maddr.
DESCRIPTION
Netstat prints information about the Linux networking subsystem. The
type of information printed is controlled by the first argument, as
follows:
(none)
By default, netstat displays a list of open sockets. If you don’t
specify any address families, then the active sockets of all configured
address families will be printed.
--route , -r
Display the kernel routing tables.
--groups , -g
Display multicast group membership information for IPv4 and IPv6.
--interfaces=iface , -I=iface , -i
Display a table of all network interfaces, or the specified iface.
--masquerade , -M
Display a list of masqueraded connections.
--statistics , -s
Display summary statistics for each protocol.
OPTIONS
--verbose , -v
Tell the user what is going on by being verbose. Especially print some
useful information about unconfigured address families.
--numeric , -n
Show numerical addresses instead of trying to determine symbolic host,
port or user names.
--numeric-hosts
shows numerical host addresses but does not affect the resolution of
port or user names.
--numeric-ports
shows numerical port numbers but does not affect the resolution of host
or user names.
--numeric-users
shows numerical user IDs but does not affect the resolution of host or
port names.
--protocol=family , -A
Specifies the address families (perhaps better described as low level
protocols) for which connections are to be shown. family is a comma
(’,’) separated list of address family keywords like inet, inet6, unix,
ipx, ax25, netrom, and ddp. This has the same effect as using the
--inet, --inet6, --unix (-x), --ipx, --ax25, --netrom, and --ddp
options.
The address family inet includes raw, udp and tcp protocol sockets.
-c, --continuous
This will cause netstat to print the selected information every second
continuously.
-e, --extend
Display additional information. Use this option twice for maximum
detail.
-o, --timers
Include information related to networking timers.
-p, --program
Show the PID and name of the program to which each socket belongs.
-l, --listening
Show only listening sockets. (These are omitted by default.)
-a, --all
Show both listening and non-listening (for TCP this means established
connections) sockets. With the --interfaces option, show interfaces
that are not marked
-F
Print routing information from the FIB. (This is the default.)
-C
Print routing information from the route cache.
-Z --context
If SELinux enabled print SELinux context.
-T --notrim
Stop trimming long addresses.
delay
Netstat will cycle printing through statistics every delay seconds.
UP.
OUTPUT
Active Internet connections (TCP, UDP, raw)
Proto
The protocol (tcp, udp, raw) used by the socket.
Recv-Q
The count of bytes not copied by the user program connected to this
socket.
Send-Q
The count of bytes not acknowledged by the remote host.
Local Address
Address and port number of the local end of the socket. Unless the
--numeric (-n) option is specified, the socket address is resolved to
its canonical host name (FQDN), and the port number is translated into
the corresponding service name.
Foreign Address
Address and port number of the remote end of the socket. Analogous to
"Local Address."
State
The state of the socket. Since there are no states in raw mode and usu-
ally no states used in UDP, this column may be left blank. Normally
this can be one of several values:
ESTABLISHED
The socket has an established connection.
SYN_SENT
The socket is actively attempting to establish a connection.
SYN_RECV
A connection request has been received from the network.
FIN_WAIT1
The socket is closed, and the connection is shutting down.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown
from the remote end.
TIME_WAIT
The socket is waiting after close to handle packets still in the
network.
CLOSED The socket is not being used.
CLOSE_WAIT
The remote end has shut down, waiting for the socket to close.
LAST_ACK
The remote end has shut down, and the socket is closed. Waiting
for acknowledgement.
LISTEN The socket is listening for incoming connections. Such sockets
are not included in the output unless you specify the --listen-
ing (-l) or --all (-a) option.
CLOSING
Both sockets are shut down but we still don’t have all our data
sent.
UNKNOWN
The state of the socket is unknown.
User
The username or the user id (UID) of the owner of the socket.
PID/Program name
Slash-separated pair of the process id (PID) and process name of the
process that owns the socket. --program causes this column to be
included. You will also need superuser privileges to see this informa-
tion on sockets you don’t own. This identification information is not
yet available for IPX sockets.
Timer
(this needs to be written)
Active UNIX domain Sockets
Proto
The protocol (usually unix) used by the socket.
RefCnt
The reference count (i.e. attached processes via this socket).
Flags
The flags displayed is SO_ACCEPTON (displayed as ACC), SO_WAITDATA (W)
or SO_NOSPACE (N). SO_ACCECPTON is used on unconnected sockets if
their corresponding processes are waiting for a connect request. The
other flags are not of normal interest.
Type
There are several types of socket access:
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
This field will contain one of the following Keywords:
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
Process ID (PID) and process name of the process that has the socket
open. More info available in Active Internet connections section writ-
ten above.
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
ss(8),ip(8)
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
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa