]> git.saurik.com Git - apple/network_cmds.git/blame - netstat.tproj/netstat.1
network_cmds-329.2.tar.gz
[apple/network_cmds.git] / netstat.tproj / netstat.1
CommitLineData
b7080c8e
A
1.\" Copyright (c) 1983, 1990, 1992, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
7ba0088d 33.\" $FreeBSD: src/usr.bin/netstat/netstat.1,v 1.22.2.7 2001/08/10 09:07:09 ru Exp $
b7080c8e 34.\"
7ba0088d 35.Dd June 15, 2001
b7080c8e 36.Dt NETSTAT 1
7ba0088d 37.Os Darwin
b7080c8e
A
38.Sh NAME
39.Nm netstat
40.Nd show network status
41.Sh SYNOPSIS
7ba0088d
A
42.Nm
43.Op Fl AaLlnW
44.Op Fl f Ar address_family | Fl p Ar protocol
7ba0088d
A
45.Nm
46.Op Fl gilns
b7080c8e 47.Op Fl f Ar address_family
7ba0088d
A
48.Nm
49.Fl i | I Ar interface
50.Op Fl w Ar wait
51.Op Fl abdgt
7ba0088d
A
52.Nm
53.Fl s Op Fl s
54.Op Fl f Ar address_family | Fl p Ar protocol
b8dff150 55.Op Fl w Ar wait
7ba0088d
A
56.Nm
57.Fl i | I Ar interface Fl s
58.Op Fl f Ar address_family | Fl p Ar protocol
7ba0088d
A
59.Nm
60.Fl m
b8dff150 61.Op Fl m
7ba0088d
A
62.Nm
63.Fl r
64.Op Fl Aaln
65.Op Fl f Ar address_family
7ba0088d
A
66.Nm
67.Fl rs
68.Op Fl s
7ba0088d 69.\"-----------------------------------------------------------------------------------------
b7080c8e 70.Sh DESCRIPTION
7ba0088d 71.\"-----------------------------------------------------------------------------------------
b7080c8e 72The
7ba0088d
A
73.Nm
74command symbolically displays the contents of various network-related data structures.
75There are a number of output formats, depending on the options for the information presented.
76The first form of the command displays a list of active sockets for each protocol.
77The second form presents the contents of one of the other network data structures according
78to the option selected. Using the third form, with a
b7080c8e
A
79.Ar wait
80interval specified,
7ba0088d
A
81.Nm
82will continuously display the information regarding packet traffic on the configured network
b8dff150
A
83interfaces. The fourth form displays statistics for the specified protocol or address family. If a
84.Ar wait
85interval is specified, the protocol information over the last interval seconds will be displayed.
7ba0088d
A
86The fifth form displays per-interface statistics for the specified protocol or address family.
87The sixth form displays
88.Xr mbuf 9
89statistics. The seventh form displays routing table for the specified address family. The
90eighth form displays routing statistics.
b7080c8e
A
91.Pp
92The options have the following meaning:
93.Bl -tag -width flag
94.It Fl A
7ba0088d
A
95With the default display, show the address of any protocol control blocks associated with
96sockets; used for debugging.
b7080c8e 97.It Fl a
7ba0088d
A
98With the default display, show the state of all sockets; normally sockets used by server
99processes are not shown. With the routing table display (option
100.Fl r ,
101as described below), show protocol-cloned routes (routes generated by a
102.Dv RTF_PRCLONING
103parent route); normally these routes are not shown.
104.It Fl b
105With the interface display (option
106.Fl i ,
107as described below), show the number of bytes in and out.
b7080c8e
A
108.It Fl d
109With either interface display (option
110.Fl i
7ba0088d
A
111or an interval, as described below), show the number of dropped packets.
112.It Fl f Ar address_family
113Limit statistics or address control block reports to those of the specified
b7080c8e 114.Ar address family .
7ba0088d 115The following address families are recognized:
b7080c8e
A
116.Ar inet ,
117for
118.Dv AF_INET ,
7ba0088d 119.Ar inet6 ,
b7080c8e 120for
7ba0088d 121.Dv AF_INET6
b7080c8e
A
122and
123.Ar unix ,
124for
125.Dv AF_UNIX .
126.It Fl g
7ba0088d
A
127Show information related to multicast (group address) routing. By default, show the
128IP Multicast virtual-interface and routing tables. If the
b7080c8e
A
129.Fl s
130option is also present, show multicast routing statistics.
7ba0088d
A
131.It Fl I Ar interface
132Show information about the specified interface; used with a
b7080c8e
A
133.Ar wait
134interval as described below.
b7080c8e 135If the
7ba0088d
A
136.Fl s
137option is present, show per-interface protocol statistics on the
138.Ar interface
139for the specified
140.Ar address_family
141or
142.Ar protocol ,
143or for all protocol families.
144.It Fl i
145Show the state of interfaces which have been auto-configured (interfaces statically
146configured into a system, but not located at boot time are not shown). If the
b7080c8e 147.Fl a
7ba0088d
A
148options is also present, multicast addresses currently in use are shown for each
149Ethernet interface and for each IP interface address. Multicast addresses are shown
150on separate lines following the interface address with which they are associated.
151If the
152.Fl s
153option is present, show per-interface statistics on all interfaces for the specified
154.Ar address_family
155or
156.Ar protocol ,
157or for all protocol families.
158.It Fl L
159Show the size of the various listen queues. The first count shows the number of
160unaccepted connections. The second count shows the amount of unaccepted incomplete
161connections. The third count is the maximum number of queued connections.
162.It Fl l
163Print full IPv6 address.
b7080c8e 164.It Fl m
b8dff150
A
165Show statistics recorded by the memory management routines (the network stack manages a private pool of memory buffers). More detailed information about the buffers, which includes their cache related statistics, can be obtained by using
166.Fl mm
167or
168.Fl m
169.Fl m
170option.
b7080c8e
A
171.It Fl n
172Show network addresses as numbers (normally
7ba0088d
A
173.Nm
174interprets addresses and attempts to display them symbolically). This option may be
175used with any of the display formats.
176.It Fl p Ar protocol
b7080c8e 177Show statistics about
7ba0088d
A
178.Ar protocol ,
179which is either a well-known name for a protocol or an alias for it. Some protocol
180names and aliases are listed in the file
b7080c8e 181.Pa /etc/protocols .
7ba0088d
A
182The special protocol name
183.Dq bdg
184is used to show bridging statistics. A null response typically means that there are
185no interesting numbers to report. The program will complain if
b7080c8e
A
186.Ar protocol
187is unknown or if there is no statistics routine for it.
b7080c8e 188.It Fl r
7ba0088d
A
189Show the routing tables. Use with
190.Fl a
191to show protocol-cloned routes. When
b7080c8e 192.Fl s
7ba0088d
A
193is also present, show routing statistics instead. When
194.Fl l
195is also present,
196.Nm
197assumes more columns are there and the maximum transmission unit
198.Pq Dq mtu
199are also displayed.
200.It Fl s
201Show per-protocol statistics. If this option is repeated, counters with a value of
202zero are suppressed.
203.It Fl W
204In certain displays, avoid truncating addresses even if this causes some fields to
205overflow.
b7080c8e 206.It Fl w Ar wait
b8dff150 207Show network interface or protocol statistics at intervals of
b7080c8e
A
208.Ar wait
209seconds.
210.El
211.Pp
7ba0088d
A
212.\"-------------------------------------------------------------------------------
213.Sh OUTPUT
214.\"-------------------------------------------------------------------------------
215The default display, for active sockets, shows the local and remote addresses,
216send and receive queue sizes (in bytes), protocol, and the internal state of
217the protocol. Address formats are of the form
218.Dq host.port
219or
220.Dq network.port
b7080c8e 221if a socket's address specifies a network but no specific host address.
7ba0088d
A
222If known, the host and network addresses are displayed symbolically
223according to the databases
b7080c8e
A
224.Pa /etc/hosts
225and
226.Pa /etc/networks ,
7ba0088d 227respectively. If a symbolic name for an address is unknown, or if the
b7080c8e 228.Fl n
7ba0088d
A
229option is specified, the address is printed numerically, according to the
230address family. For more information regarding the Internet
231.Dq dot format ,
b7080c8e
A
232refer to
233.Xr inet 3 ) .
234Unspecified,
7ba0088d
A
235or
236.Dq wildcard ,
237addresses and ports appear as
238.Dq * .
239.Pp
240Internet domain socket states:
241.Bl -column X LISTEN
242CLOSED: The socket is not in use.
243.Pp
244LISTEN: The socket is listening for incoming connections. Unconnected
245listening sockets like these are only displayed when using the -a option.
246.Pp
247SYN_SENT: The socket is actively trying to establish a connection to a
248remote peer.
b7080c8e 249.Pp
7ba0088d
A
250SYN_RCVD: The socket has passively received a connection request from a
251remote peer.
b7080c8e 252.Pp
7ba0088d
A
253ESTABLISHED: The socket has an established connection between a local
254application and a remote peer.
255.Pp
256CLOSE_WAIT: The socket connection has been closed by the remote peer,
257and the system is waiting for the local application to close its half of
258the connection.
259.Pp
260LAST_ACK: The socket connection has been closed by the remote peer, the
261local application has closed its half of the connection, and the system
262is waiting for the remote peer to acknowledge the close.
263.Pp
264FIN_WAIT_1: The socket connection has been closed by the local
265application, the remote peer has not yet acknowledged the close, and the
266system is waiting for it to close its half of the connection.
267.Pp
268FIN_WAIT_2: The socket connection has been closed by the local
269application, the remote peer has acknowledged the close, and the system
270is waiting for it to close its half of the connection.
271.Pp
272CLOSING: The socket connection has been closed by the local application
273and the remote peer simultaneously, and the remote peer has not yet
274acknowledged the close attempt of the local application.
275.Pp
276TIME_WAIT: The socket connection has been closed by the local
277application, the remote peer has closed its half of the connection, and
278the system is waiting to be sure that the remote peer received the last
279acknowledgement.
280.El
281.Pp
282The interface display provides a table of cumulative statistics regarding
283packets transferred, errors, and collisions. The network addresses of the
284interface and the maximum transmission unit
285.Pq Dq mtu
286are also displayed.
287.Pp
288The routing table display indicates the available routes and their status.
289Each route consists of a destination host or network and a gateway to use
290in forwarding packets. The flags field shows a collection of information
291about the route stored as binary choices. The individual flags are discussed
292in more detail in the
b7080c8e
A
293.Xr route 8
294and
295.Xr route 4
7ba0088d 296manual pages. The mapping between letters and flags is:
b7080c8e 297.Bl -column XXXX RTF_BLACKHOLE
7ba0088d
A
2981 RTF_PROTO1 Protocol specific routing flag #1
2992 RTF_PROTO2 Protocol specific routing flag #2
3003 RTF_PROTO3 Protocol specific routing flag #3
301B RTF_BLACKHOLE Just discard packets (during updates)
302b RTF_BROADCAST The route represents a broadcast address
303C RTF_CLONING Generate new routes on use
304c RTF_PRCLONING Protocol-specified generate new routes on use
305D RTF_DYNAMIC Created dynamically (by redirect)
b7080c8e 306G RTF_GATEWAY Destination requires forwarding by intermediary
7ba0088d 307H RTF_HOST Host entry (net otherwise)
9c859447 308I RTF_IFSCOPE Route is associated with an interface scope
7f5b2e89 309i RTF_IFREF Route is holding a reference to the interface
7ba0088d
A
310L RTF_LLINFO Valid protocol to link address translation
311M RTF_MODIFIED Modified dynamically (by redirect)
9c859447 312m RTF_MULTICAST The route represents a multicast address
7ba0088d
A
313R RTF_REJECT Host or net unreachable
314S RTF_STATIC Manually added
315U RTF_UP Route usable
316W RTF_WASCLONED Route was generated as a result of cloning
b7080c8e
A
317X RTF_XRESOLVE External daemon translates proto to link address
318.El
319.Pp
7ba0088d
A
320Direct routes are created for each interface attached to the local host;
321the gateway field for such entries shows the address of the outgoing
322interface. The refcnt field gives the current number of active uses of
323the route. Connection oriented protocols normally hold on to a single
324route for the duration of a connection while connectionless protocols
325obtain a route while sending to the same destination. The use field
326provides a count of the number of packets sent using that route. The
327interface entry indicates the network interface utilized for the route.
9c859447
A
328A route which is marked with the RTF_IFSCOPE flag is instantiated for
329the corresponding interface.
b7080c8e
A
330.Pp
331When
332.Nm netstat
333is invoked with the
334.Fl w
335option and a
336.Ar wait
337interval argument, it displays a running count of statistics related to
b8dff150 338network interfaces or protocols. An obsolete version of this option used a numeric
7ba0088d
A
339parameter with no option, and is currently supported for backward
340compatibility. By default, this display summarizes information for all
341interfaces. Information for a specific interface may be displayed with the
b7080c8e
A
342.Fl I
343option.
b7080c8e 344.Sh SEE ALSO
7ba0088d 345.Xr fstat 1 ,
b7080c8e
A
346.Xr nfsstat 1 ,
347.Xr ps 1 ,
7ba0088d
A
348.Xr sockstat 1 ,
349.Xr inet 4 ,
350.Xr unix 4 ,
b7080c8e
A
351.Xr hosts 5 ,
352.Xr networks 5 ,
353.Xr protocols 5 ,
9c859447 354.Xr route 8 ,
b7080c8e 355.Xr services 5 ,
7ba0088d 356.Xr iostat 8 ,
b7080c8e 357.Xr trpt 8 ,
7ba0088d 358.Xr vmstat 8
b7080c8e
A
359.Sh HISTORY
360The
361.Nm netstat
362command appeared in
363.Bx 4.2 .
7ba0088d
A
364.Pp
365IPv6 support was added by WIDE/KAME project.
b7080c8e
A
366.Sh BUGS
367The notion of errors is ill-defined.