xref: /openbsd-src/usr.bin/netstat/netstat.1 (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1.\"	$OpenBSD: netstat.1,v 1.66 2011/09/03 22:59:07 jmc Exp $
2.\"	$NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $
3.\"
4.\" Copyright (c) 1983, 1990, 1992, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	from: @(#)netstat.1	8.8 (Berkeley) 4/18/94
32.\"
33.Dd $Mdocdate: September 3 2011 $
34.Dt NETSTAT 1
35.Os
36.Sh NAME
37.Nm netstat
38.Nd show network status
39.Sh SYNOPSIS
40.Nm netstat
41.Op Fl AaBn
42.Op Fl f Ar address_family
43.Op Fl p Ar protocol
44.Op Fl M Ar core
45.Op Fl N Ar system
46.Nm netstat
47.Bk -words
48.Op Fl bdFgilmnqrstu
49.Op Fl f Ar address_family
50.Op Fl p Ar protocol
51.Op Fl M Ar core
52.Op Fl N Ar system
53.Op Fl T Ar tableid
54.Ek
55.Nm netstat
56.Op Fl bdn
57.Op Fl c Ar count
58.Op Fl I Ar interface
59.Op Fl M Ar core
60.Op Fl N Ar system
61.Op Fl w Ar wait
62.Nm netstat
63.Op Fl v
64.Op Fl M Ar core
65.Op Fl N Ar system
66.Fl P Ar pcbaddr
67.Nm netstat
68.Op Fl s
69.Op Fl M Ar core
70.Op Fl N Ar system
71.Op Fl p Ar protocol
72.Nm netstat
73.Op Fl a
74.Op Fl f Ar address_family
75.Op Fl p Ar protocol
76.Op Fl i | I Ar interface
77.Nm netstat
78.Op Fl W Ar interface
79.Sh DESCRIPTION
80The
81.Nm
82command symbolically displays the contents of various network-related
83data structures.
84There are a number of output formats,
85depending on the options for the information presented.
86.Pp
87The first form of the command displays a list of active sockets for
88each protocol.
89The second form presents the contents of one of the other network
90data structures according to the option selected.
91Using the third form, with a
92.Ar wait
93interval specified,
94.Nm
95will continuously display the information regarding packet
96traffic on the configured network interfaces.
97The fourth form displays internals of the protocol control block (PCB)
98and the socket structure.
99The fifth form displays statistics about the named protocol.
100The sixth form displays per interface statistics for
101the specified address family.
102The final form displays per interface statistics for
103the specified wireless (802.11) device.
104.Pp
105The options are as follows:
106.Bl -tag -width Ds
107.It Fl A
108With the default display,
109show the address of any protocol control blocks associated with sockets; used
110for debugging, e.g. with the
111.Fl P
112flag.
113.It Fl a
114With the default display,
115show the state of all sockets; normally sockets used by
116server processes are not shown.
117With the interface display (options
118.Fl I
119or
120.Fl i ) ,
121show multicast addresses.
122.It Fl B
123With the default display,
124show buffer sizes for TCP sockets.
125This includes the send window size, receive window size and congestion
126window size.
127.It Fl b
128With the interface display (options
129.Fl I
130or
131.Fl i ) ,
132show bytes in and out, instead of packet statistics.
133.It Fl c Ar count
134Display
135.Ar count
136updates, then exit.
137This option has no effect unless
138.Fl w
139is specified as well.
140.It Fl d
141With either the interface display (options
142.Fl I
143or
144.Fl i )
145or an interval (option
146.Fl w ) ,
147show the number of dropped packets.
148.It Fl F
149When showing routes, only show routes whose gateway are in the
150same address family as the destination.
151.It Fl f Ar address_family
152Limit statistics or address control block reports to those
153of the specified
154.Ar address_family .
155.Pp
156The following address families are recognized:
157.Bl -column "Address Family" "AF_APPLETA" "Description" -offset indent
158.It Sy "Address Family" Ta Sy "Constant" Ta Sy "Description"
159.It "encap" Ta Dv "PF_KEY" Ta "IPsec"
160.It "inet" Ta Dv "AF_INET" Ta "IP Version 4"
161.It "inet6" Ta Dv "AF_INET6" Ta "IP Version 6"
162.It "local" Ta Dv "AF_LOCAL" Ta "Local to Host (i.e., pipes)"
163.It "mpls" Ta Dv "AF_MPLS" Ta "MPLS"
164.It "pflow" Ta Dv "PF_FLOW" Ta "pflow data export"
165.It "unix" Ta Dv "AF_UNIX" Ta "Local to Host (i.e., pipes)"
166.El
167.Pp
168.It Fl g
169Show information related to multicast (group address) routing.
170By default, show the IP multicast virtual-interface and routing tables.
171If the
172.Fl s
173option is also present, show multicast routing statistics.
174.It Fl I Ar interface
175Show information about the specified
176.Ar interface ;
177used with a
178.Ar wait
179interval as described below.
180.Pp
181If the
182.Fl a
183option is also present, multicast addresses currently in use are shown
184for the given interface and for each IP interface address.
185Multicast addresses are shown on separate lines following the interface
186address with which they are associated.
187.Pp
188If the
189.Fl f Ar address_family
190option (with the
191.Fl s
192option) is present, show per-interface
193statistics on the given interface for the specified
194.Ar address_family .
195.It Fl i
196Show the state of interfaces which have been auto-configured
197(interfaces statically configured into a system but not
198located at boot-time are not shown).
199.Pp
200If the
201.Fl a
202option is also present, multicast addresses currently in use are shown
203for each Ethernet interface and for each IP interface address.
204Multicast addresses are shown on separate lines following the interface
205address with which they are associated.
206.Pp
207If the
208.Fl f Ar address_family
209option (with the
210.Fl s
211option) is present, show per-interface statistics on all interfaces
212for the specified
213.Ar address_family .
214.It Fl l
215With the
216.Fl g
217option, display wider fields for the IPv6 multicast routing table
218.Qq Origin
219and
220.Qq Group
221columns.
222.It Fl M Ar core
223Extract values associated with the name list from the specified core
224instead of the running kernel.
225.It Fl m
226Show statistics recorded by the memory management routines
227(the network manages a private pool of memory buffers).
228.It Fl N Ar system
229Extract the name list from the specified system instead of the running kernel.
230.It Fl n
231Show network addresses as numbers (normally
232.Nm
233interprets addresses and attempts to display them
234symbolically).
235This option may be used with any of the display formats.
236.It Fl P Ar pcbaddr
237Display the contents of the socket or protocol control block (PCB)
238located at the kernel virtual address
239.Ar pcbaddr .
240PCB addresses can be obtained using the
241.Fl A
242flag.
243When used with the
244.Fl v
245option, also print socket, domain and protocol specific structures.
246.It Fl p Ar protocol
247Restrict the output to
248.Ar protocol ,
249which is either a well-known name for a protocol or an alias for it.
250Some protocol names and aliases are listed in the file
251.Pa /etc/protocols .
252The program will complain if
253.Ar protocol
254is unknown.
255If the
256.Fl s
257option is specified, the per-protocol statistics are displayed.
258Otherwise the states of the matching sockets are shown.
259.It Fl q
260Only show interfaces that have seen packets (or bytes if
261.Fl b
262is specified).
263.It Fl r
264Show the routing tables.
265If the
266.Fl s
267option is also specified, show routing statistics instead.
268When used with the
269.Fl v
270option, also print routing labels.
271.It Fl s
272Show per-protocol statistics.
273If this option is repeated, counters with a value of zero are suppressed.
274.It Fl T Ar tableid
275Select an alternate routing table to modify or query.
276Table 0 is the default table.
277.It Fl t
278With the
279.Fl i
280option, display the current value of the watchdog timer function.
281.It Fl u
282Limit statistics or address control block reports to the
283.Dv AF_UNIX
284address family.
285.It Fl v
286Show extra (verbose) detail for the routing tables
287.Pq Fl r ,
288or avoid truncation of long addresses.
289When used with the
290.Fl P
291option, also print socket, domain and protocol specific structures.
292.It Fl W Ar interface
293(IEEE 802.11 devices only)
294Show per-interface IEEE 802.11 wireless statistics.
295.It Fl w Ar wait
296Show network interface statistics at intervals of
297.Ar wait
298seconds.
299.El
300.Pp
301The default display, for active sockets, shows the local
302and remote addresses, send and receive queue sizes (in bytes), protocol,
303and the internal state of the protocol.
304.Pp
305Address formats are of the form
306.Dq host.port
307or
308.Dq network.port
309if a socket's address specifies a network but no specific host address.
310When known, the host and network addresses are displayed symbolically
311according to the databases
312.Pa /etc/hosts
313and
314.Pa /etc/networks ,
315respectively.
316If a symbolic name for an address is unknown, or if the
317.Fl n
318option is specified, the address is printed numerically, according
319to the address family.
320.Pp
321For more information regarding the Internet
322.Dq dot format ,
323refer to
324.Xr inet 3 .
325Unspecified or
326.Dq wildcard
327addresses and ports appear as a single
328.Sq * .
329If a local port number is registered as being in use for RPC by
330.Xr portmap 8 ,
331its RPC service name or RPC service number will be printed in
332.Dq []
333immediately after the port number.
334.Pp
335The interface display provides a table of cumulative
336statistics regarding packets transferred, errors, and collisions.
337The network addresses of the interface
338and the maximum transmission unit (MTU) are also displayed.
339.Pp
340The routing table display indicates the available routes and their status.
341Each route consists of a destination host or network and
342a gateway to use in forwarding packets.
343If the destination is a
344network in numeric format, the netmask (in /24 style format) is appended.
345The flags field shows a collection of information about
346the route stored as binary choices.
347The individual flags are discussed in more detail in the
348.Xr route 8
349and
350.Xr route 4
351manual pages.
352.Pp
353The mapping between letters and flags is:
354.Bl -column "1" "RTF_BLACKHOLE" "Protocol specific routing flag #1."
355.It 1 Ta RTF_PROTO1 Ta "Protocol specific routing flag #1."
356.It 2 Ta RTF_PROTO2 Ta "Protocol specific routing flag #2."
357.It 3 Ta RTF_PROTO3 Ta "Protocol specific routing flag #3."
358.It B Ta RTF_BLACKHOLE Ta "Just discard pkts (during updates)."
359.It C Ta RTF_CLONING Ta "Generate new routes on use."
360.It c Ta RTF_CLONED Ta "Cloned routes (generated from RTF_CLONING)."
361.It D Ta RTF_DYNAMIC Ta "Created dynamically (by redirect)."
362.It G Ta RTF_GATEWAY Ta "Destination requires forwarding by intermediary."
363.It H Ta RTF_HOST Ta "Host entry (net otherwise)."
364.It L Ta RTF_LLINFO Ta "Valid protocol to link address translation."
365.It M Ta RTF_MODIFIED Ta "Modified dynamically (by redirect)."
366.It P Ta RTF_MPATH Ta "Multipath route."
367.It R Ta RTF_REJECT Ta "Host or net unreachable."
368.It S Ta RTF_STATIC Ta "Manually added."
369.It T Ta RTF_MPLS Ta "MPLS route."
370.It U Ta RTF_UP Ta "Route usable."
371.It X Ta RTF_XRESOLVE Ta "External daemon translates proto to link address."
372.El
373.Pp
374Direct routes are created for each interface attached to the local host;
375the gateway field for such entries shows the address of the outgoing interface.
376The refcnt field gives the current number of active uses of the route.
377Connection oriented protocols normally hold on to a single route for the
378duration of a connection while connectionless protocols obtain a route while
379sending to the same destination.
380The use field provides a count of the number of packets sent using that route.
381The MTU entry shows the MTU associated with that route.
382This MTU value is used as the basis for the TCP maximum segment size (MSS).
383The
384.Sq L
385flag appended to the MTU value indicates that the value is
386locked, and that path MTU discovery is turned off for that route.
387A
388.Sq -
389indicates that the MTU for this route has not been set, and a default
390TCP maximum segment size will be used.
391The interface entry indicates the network interface utilized for the route.
392.Pp
393When
394.Nm
395is invoked with the
396.Fl w
397option and a
398.Ar wait
399interval argument, it displays a running count of statistics related to
400network interfaces.
401An obsolescent version of this option used a numeric parameter
402with no option, and is currently supported for backward compatibility.
403This display consists of a column for the primary interface (the first
404interface found during autoconfiguration) and a column summarizing
405information for all interfaces.
406The primary interface may be replaced with another interface with the
407.Fl I
408option.
409The first line of each screen of information contains a summary since the
410system was last rebooted.
411Subsequent lines of output show values accumulated over the preceding interval.
412.Sh SEE ALSO
413.Xr fstat 1 ,
414.Xr nfsstat 1 ,
415.Xr ps 1 ,
416.Xr systat 1 ,
417.Xr tcpbench 1 ,
418.Xr top 1 ,
419.Xr inet 3 ,
420.Xr netintro 4 ,
421.Xr route 4 ,
422.Xr hosts 5 ,
423.Xr networks 5 ,
424.Xr protocols 5 ,
425.Xr services 5 ,
426.Xr iostat 8 ,
427.Xr portmap 8 ,
428.Xr pstat 8 ,
429.Xr route 8 ,
430.Xr tcpdrop 8 ,
431.Xr trpt 8 ,
432.Xr vmstat 8
433.Sh HISTORY
434The
435.Nm
436command appeared in
437.Bx 4.2 .
438IPv6 support was added by the WIDE/KAME project.
439.Sh BUGS
440The notion of errors is ill-defined.
441