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