xref: /openbsd-src/usr.bin/netstat/netstat.1 (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1.\"	$OpenBSD: netstat.1,v 1.71 2014/05/10 23:31:40 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: May 10 2014 $
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 bdhn
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.It Fl h
168Use unit suffixes to reduce the number of digits shown with the
169.Fl b
170and
171.Fl w
172options.
173.It Fl g
174Show information related to multicast (group address) routing.
175By default, show the IP multicast virtual-interface and routing tables.
176If the
177.Fl s
178option is also present, show multicast routing statistics.
179.It Fl I Ar interface
180Show information about the specified
181.Ar interface ;
182used with a
183.Ar wait
184interval as described below.
185.Pp
186If the
187.Fl a
188option is also present, multicast addresses currently in use are shown
189for the given interface and for each IP interface address.
190Multicast addresses are shown on separate lines following the interface
191address with which they are associated.
192.Pp
193If the
194.Fl f Ar address_family
195option (with the
196.Fl s
197option) is present, show per-interface
198statistics on the given interface for the specified
199.Ar address_family .
200.It Fl i
201Show the state of interfaces which have been auto-configured
202(interfaces statically configured into a system but not
203located at boot-time are not shown).
204.Pp
205If the
206.Fl a
207option is also present, multicast addresses currently in use are shown
208for each Ethernet interface and for each IP interface address.
209Multicast addresses are shown on separate lines following the interface
210address with which they are associated.
211.Pp
212If the
213.Fl f Ar address_family
214option (with the
215.Fl s
216option) is present, show per-interface statistics on all interfaces
217for the specified
218.Ar address_family .
219.It Fl l
220With the
221.Fl g
222option, display wider fields for the IPv6 multicast routing table
223.Qq Origin
224and
225.Qq Group
226columns.
227.It Fl M Ar core
228Extract values associated with the name list from the specified core
229instead of the running kernel.
230.It Fl m
231Show statistics recorded by the memory management routines
232(the network manages a private pool of memory buffers).
233.It Fl N Ar system
234Extract the name list from the specified system instead of the running kernel.
235.It Fl n
236Show network addresses as numbers (normally
237.Nm
238interprets addresses and attempts to display them
239symbolically).
240This option may be used with any of the display formats.
241.It Fl P Ar pcbaddr
242Display the contents of the socket or protocol control block (PCB)
243located at the kernel virtual address
244.Ar pcbaddr .
245PCB addresses can be obtained using the
246.Fl A
247flag.
248When used with the
249.Fl v
250option, also print socket, domain and protocol specific structures.
251.It Fl p Ar protocol
252Restrict the output to
253.Ar protocol ,
254which is either a well-known name for a protocol or an alias for it.
255Some protocol names and aliases are listed in the file
256.Pa /etc/protocols .
257The program will complain if
258.Ar protocol
259is unknown.
260If the
261.Fl s
262option is specified, the per-protocol statistics are displayed.
263Otherwise the states of the matching sockets are shown.
264.It Fl q
265Only show interfaces that have seen packets (or bytes if
266.Fl b
267is specified).
268.It Fl r
269Show the routing tables.
270If the
271.Fl s
272option is also specified, show routing statistics instead.
273When used with the
274.Fl v
275option, also print routing labels.
276.It Fl s
277Show per-protocol statistics.
278If this option is repeated, counters with a value of zero are suppressed.
279.It Fl T Ar tableid
280Select an alternate routing table to query.
281The default is to use the current routing table.
282.It Fl t
283With the
284.Fl i
285option, display the current value of the watchdog timer function.
286.It Fl u
287Limit statistics or address control block reports to the
288.Dv AF_UNIX
289address family.
290.It Fl v
291Show extra (verbose) detail for the routing tables
292.Pq Fl r ,
293or avoid truncation of long addresses.
294When used with the
295.Fl P
296option, also print socket, domain and protocol specific structures.
297.It Fl W Ar interface
298(IEEE 802.11 devices only)
299Show per-interface IEEE 802.11 wireless statistics.
300.It Fl w Ar wait
301Show network interface statistics at intervals of
302.Ar wait
303seconds.
304.El
305.Pp
306The default display, for active sockets, shows the local
307and remote addresses, send and receive queue sizes (in bytes), protocol,
308and the internal state of the protocol.
309.Pp
310Address formats are of the form
311.Dq host.port
312or
313.Dq network.port
314if a socket's address specifies a network but no specific host address.
315When known, the host and network addresses are displayed symbolically
316according to the databases
317.Pa /etc/hosts
318and
319.Pa /etc/networks ,
320respectively.
321If a symbolic name for an address is unknown, or if the
322.Fl n
323option is specified, the address is printed numerically, according
324to the address family.
325.Pp
326For more information regarding the Internet
327.Dq dot format ,
328refer to
329.Xr inet_ntop 3 .
330Unspecified or
331.Dq wildcard
332addresses and ports appear as a single
333.Sq * .
334If a local port number is registered as being in use for RPC by
335.Xr portmap 8 ,
336its RPC service name or RPC service number will be printed in
337.Dq []
338immediately after the port number.
339.Pp
340The interface display provides a table of cumulative
341statistics regarding packets transferred, errors, and collisions.
342The network addresses of the interface
343and the maximum transmission unit (MTU) are also displayed.
344.Pp
345The routing table display indicates the available routes and their status.
346Each route consists of a destination host or network and
347a gateway to use in forwarding packets.
348If the destination is a
349network in numeric format, the netmask (in /24 style format) is appended.
350The flags field shows a collection of information about
351the route stored as binary choices.
352The individual flags are discussed in more detail in the
353.Xr route 8
354and
355.Xr route 4
356manual pages.
357.Pp
358The mapping between letters and flags is:
359.Bl -column "1" "RTF_BLACKHOLE" "Protocol specific routing flag #1."
360.It 1 Ta RTF_PROTO1 Ta "Protocol specific routing flag #1."
361.It 2 Ta RTF_PROTO2 Ta "Protocol specific routing flag #2."
362.It 3 Ta RTF_PROTO3 Ta "Protocol specific routing flag #3."
363.It B Ta RTF_BLACKHOLE Ta "Just discard pkts (during updates)."
364.It b Ta RTF_BROADCAST Ta "Correspond to a local broadcast address."
365.It C Ta RTF_CLONING Ta "Generate new routes on use."
366.It c Ta RTF_CLONED Ta "Cloned routes (generated from RTF_CLONING)."
367.It D Ta RTF_DYNAMIC Ta "Created dynamically (by redirect)."
368.It G Ta RTF_GATEWAY Ta "Destination requires forwarding by intermediary."
369.It H Ta RTF_HOST Ta "Host entry (net otherwise)."
370.It L Ta RTF_LLINFO Ta "Valid protocol to link address translation."
371.It l Ta RTF_LOCAL Ta "Correspond to a local address."
372.It M Ta RTF_MODIFIED Ta "Modified dynamically (by redirect)."
373.It P Ta RTF_MPATH Ta "Multipath route."
374.It R Ta RTF_REJECT Ta "Host or net unreachable."
375.It S Ta RTF_STATIC Ta "Manually added."
376.It T Ta RTF_MPLS Ta "MPLS route."
377.It U Ta RTF_UP Ta "Route usable."
378.It X Ta RTF_XRESOLVE Ta "External daemon translates proto to link address."
379.El
380.Pp
381Direct routes are created for each interface attached to the local host;
382the gateway field for such entries shows the address of the outgoing interface.
383The refcnt field gives the current number of active uses of the route.
384Connection oriented protocols normally hold on to a single route for the
385duration of a connection while connectionless protocols obtain a route while
386sending to the same destination.
387The use field provides a count of the number of packets sent using that route.
388The MTU entry shows the MTU associated with that route.
389This MTU value is used as the basis for the TCP maximum segment size (MSS).
390The
391.Sq L
392flag appended to the MTU value indicates that the value is
393locked, and that path MTU discovery is turned off for that route.
394A
395.Sq -
396indicates that the MTU for this route has not been set, and a default
397TCP maximum segment size will be used.
398The interface entry indicates the network interface utilized for the route.
399.Pp
400When
401.Nm
402is invoked with the
403.Fl w
404option and a
405.Ar wait
406interval argument, it displays a running count of statistics related to
407network interfaces.
408An obsolescent version of this option used a numeric parameter
409with no option, and is currently supported for backward compatibility.
410This display consists of a column for the primary interface (the first
411interface found during autoconfiguration) and a column summarizing
412information for all interfaces.
413The primary interface may be replaced with another interface with the
414.Fl I
415option.
416The first line of each screen of information contains a summary since the
417system was last rebooted.
418Subsequent lines of output show values accumulated over the preceding interval.
419.Sh SEE ALSO
420.Xr fstat 1 ,
421.Xr nfsstat 1 ,
422.Xr ps 1 ,
423.Xr systat 1 ,
424.Xr tcpbench 1 ,
425.Xr top 1 ,
426.Xr inet_ntop 3 ,
427.Xr netintro 4 ,
428.Xr route 4 ,
429.Xr hosts 5 ,
430.Xr networks 5 ,
431.Xr protocols 5 ,
432.Xr services 5 ,
433.Xr iostat 8 ,
434.Xr portmap 8 ,
435.Xr pstat 8 ,
436.Xr route 8 ,
437.Xr tcpdrop 8 ,
438.Xr trpt 8 ,
439.Xr vmstat 8
440.Sh HISTORY
441The
442.Nm
443command appeared in
444.Bx 4.2 .
445IPv6 support was added by the WIDE/KAME project.
446.Sh BUGS
447The notion of errors is ill-defined.
448