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