xref: /openbsd-src/usr.bin/netstat/netstat.1 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\"	$OpenBSD: netstat.1,v 1.25 2001/06/25 00:41:39 niklas 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. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"	from: @(#)netstat.1	8.8 (Berkeley) 4/18/94
36.\"
37.Dd April 18, 1994
38.Dt NETSTAT 1
39.Os
40.Sh NAME
41.Nm netstat
42.Nd show network status
43.Sh SYNOPSIS
44.Nm netstat
45.Op Fl Aan
46.Op Fl f Ar address_family
47.Op Fl M Ar core
48.Op Fl N Ar system
49.Nm netstat
50.Op Fl bdgimnrs
51.Op Fl f Ar address_family
52.Op Fl M Ar core
53.Op Fl N Ar system
54.Nm netstat
55.Op Fl bdn
56.Op Fl I Ar interface
57.Op Fl M Ar core
58.Op Fl N Ar system
59.Op Fl w Ar wait
60.Nm netstat
61.Op Fl p Ar protocol
62.Op Fl M Ar core
63.Op Fl N Ar system
64.Nm netstat
65.Op Fl p Ar protocol
66.Op Fl i
67.Op Fl I Ar Interface
68.Nm netstat
69.Op Fl s
70.Op Fl f Ar address_family
71.Op Fl i
72.Op Fl I Ar Interface
73.Sh DESCRIPTION
74The
75.Nm
76command symbolically displays the contents of various network-related
77data structures.
78There are a number of output formats,
79depending on the options for the information presented.
80.Pp
81The first form of the command displays a list of active sockets for
82each protocol.
83The second form presents the contents of one of the other network
84data structures according to the option selected.
85Using the third form, with a
86.Ar wait
87interval specified,
88.Nm
89will continuously display the information regarding packet
90traffic on the configured network interfaces.
91The fourth form displays statistics about the named protocol.
92The fifth and sixth forms display per interface statistics for
93the specified protocol or address family.
94.Pp
95The options are as follows:
96.Bl -tag -width Ds
97.It Fl A
98With the default display,
99show the address of any protocol control blocks associated with sockets; used
100for debugging.
101.It Fl a
102With the default display,
103show the state of all sockets; normally sockets used by
104server processes are not shown.
105.It Fl b
106With the interface display (option
107.Fl i ) ,
108show bytes in and out, instead of packet statistics.
109.It Fl d
110With either interface display (option
111.Fl i
112or an interval, as described below),
113show the number of dropped packets.
114.It Fl f Ar address_family
115Limit statistics or address control block reports to those
116of the specified
117.Ar address_family .
118.Pp
119The following address families are recognized:
120.Pp
121.Bl -column "Address Family" "AF_APPLETA" "Description" -offset indent -compact
122.It Sy "Address Family" Ta Sy "Constant" Ta Sy "Description"
123.It "inet" Dv Ta "AF_INET" Ta "IP Version 4"
124.It "inet6" Dv Ta "AF_INET6" Ta "IP Version 6"
125.It "ipx" Dv Ta "AF_IPX" Ta "Novell IPX"
126.It "atalk" Dv Ta "AF_APPLETALK" Ta "AppleTalk"
127.It "ns" Dv Ta "AF_NS" Ta "Xerox NS Protocols"
128.It "iso" Dv Ta "AF_ISO" Ta "ISO Protocol Family"
129.It "encap" Dv Ta "PF_KEY" Ta "IPsec"
130.It "local" Dv Ta "AF_LOCAL" Ta "Local to Host (i.e., pipes)"
131.It "unix" Dv Ta "AF_UNIX" Ta "Local to Host (i.e., pipes)"
132.El
133.Pp
134.It Fl g
135Show information related to multicast (group address) routing.
136By default, show the IP Multicast virtual-interface and routing tables.
137If the
138.Fl s
139option is also present, show multicast routing statistics.
140.It Fl I Ar interface
141Show information about the specified
142.Ar interface ;
143used with a
144.Ar wait
145interval as described below.
146.Pp
147If the
148.Fl f Ar address_family
149option (with the
150.Fl s
151option) or the
152.Fl p Ar protocol
153option is present, show per-interface statistics on the given interface
154for the specified
155.Ar address_family
156or
157.Ar protocol ,
158respectively.
159.It Fl i
160Show the state of interfaces which have been auto-configured
161(interfaces statically configured into a system but not
162located at boot-time are not shown).
163.Pp
164If the
165.Fl a
166option is also present, multicast addresses currently in use are shown
167for each Ethernet interface and for each IP interface address.
168Multicast addresses are shown on separate lines following the interface
169address with which they are associated.
170.Pp
171If the
172.Fl f Ar address_family
173option (with the
174.Fl s
175option) or the
176.Fl p Ar protocol
177option is present, show per-interface statistics on all interfaces
178for the specified
179.Ar address_family
180or
181.Ar protocol ,
182respectively.
183.It Fl M Ar core
184Extract values associated with the name list from the specified core
185instead of the default
186.Pa /dev/kmem .
187.It Fl m
188Show statistics recorded by the memory management routines
189(the network manages a private pool of memory buffers).
190.It Fl N Ar system
191Extract the name list from the specified system instead of the default
192.Pa /bsd .
193.It Fl n
194Show network addresses as numbers (normally
195.Nm
196interprets addresses and attempts to display them
197symbolically).
198This option may be used with any of the display formats.
199.It Fl p Ar protocol
200Show statistics about
201.Ar protocol ,
202which is either a well-known name for a protocol or an alias for it.
203Some protocol names and aliases are listed in the file
204.Pa /etc/protocols .
205A null response typically means that there are no interesting numbers to
206report.
207The program will complain if
208.Ar protocol
209is unknown or if there is no statistics routine for it.
210.It Fl s
211Show per-protocol statistics.
212If this option is repeated, counters with a value of zero are suppressed.
213.It Fl r
214Show the routing tables.
215If the
216.Fl s
217option is also specified, show routing statistics instead.
218.It Fl v
219Be verbose.
220Avoids truncation of long addresses.
221.It Fl w Ar wait
222Show network interface statistics at intervals of
223.Ar wait
224seconds.
225.El
226.Pp
227The default display, for active sockets, shows the local
228and remote addresses, send and receive queue sizes (in bytes), protocol,
229and the internal state of the protocol.
230.Pp
231Address formats are of the form
232.Dq host.port
233or
234.Dq network.port
235if a socket's address specifies a network but no specific host address.
236When known, the host and network addresses are displayed symbolically
237according to the databases
238.Pa /etc/hosts
239and
240.Pa /etc/networks ,
241respectively.
242If a symbolic name for an address is unknown, or if the
243.Fl n
244option is specified, the address is printed numerically, according
245to the address family.
246.Pp
247For more information regarding the Internet
248.Dq dot format ,
249refer to
250.Xr inet 3 .
251Unspecified, or
252.Dq wildcard
253addresses and ports appear as a single
254.Dq \&* .
255If a local port number is registered as being in use for RPC by
256.Xr portmap 8 ,
257its RPC service name or RPC service number will be printed in
258.Dq []
259immediately after the port number.
260.Pp
261The interface display provides a table of cumulative
262statistics regarding packets transferred, errors, and collisions.
263The network addresses of the interface
264and the maximum transmission unit (MTU) are also displayed.
265.Pp
266The routing table display indicates the available routes and their status.
267Each route consists of a destination host or network and
268a gateway to use in forwarding packets.
269If the destination is a
270network in numeric format, the netmask (in /24 style format) is appended.
271The flags field shows a collection of information about
272the route stored as binary choices.
273The individual flags are discussed in more detail in the
274.Xr route 8
275and
276.Xr route 4
277manual pages.
278.Pp
279The mapping between letters and flags is:
280.Bl -column XXXX RTF_BLACKHOLE
2811	RTF_PROTO1	Protocol specific routing flag #1.
2822	RTF_PROTO2	Protocol specific routing flag #2.
2833	RTF_PROTO3	Protocol specific routing flag #3.
284B	RTF_BLACKHOLE	Just discard pkts (during updates).
285C	RTF_CLONING	Generate new routes on use.
286D	RTF_DYNAMIC	Created dynamically (by redirect).
287G	RTF_GATEWAY	Destination requires forwarding by intermediary.
288H	RTF_HOST	Host entry (net otherwise).
289L	RTF_LLINFO	Valid protocol to link address translation.
290M	RTF_MODIFIED	Modified dynamically (by redirect).
291R	RTF_REJECT	Host or net unreachable.
292S	RTF_STATIC	Manually added.
293U	RTF_UP	Route usable.
294X	RTF_XRESOLVE	External daemon translates proto to link address.
295.El
296.Pp
297Direct routes are created for each interface attached to the local host;
298the gateway field for such entries shows the address of the outgoing interface.
299The refcnt field gives the current number of active uses of the route.
300Connection oriented protocols normally hold on to a single route for the
301duration of a connection while connectionless protocols obtain a route while
302sending to the same destination.
303The use field provides a count of the number of packets sent using that route.
304The MTU entry shows the MTU associated with that route.
305This MTU value is used as the basis for the TCP maximum segment size (MSS).
306The 'L' flag appended to the mtu value indicates that the value is
307locked, and that path mtu discovery is turned off for that route.
308A
309.Sq -
310indicates that the MTU for this route has not been set, and a default
311TCP maximum segment size will be used.
312The interface entry indicates the network interface utilized for the route.
313.Pp
314When
315.Nm
316is invoked with the
317.Fl w
318option and a
319.Ar wait
320interval argument, it displays a running count of statistics related to
321network interfaces.
322An obsolescent version of this option used a numeric parameter
323with no option, and is currently supported for backward compatibility.
324This display consists of a column for the primary interface (the first
325interface found during autoconfiguration) and a column summarizing
326information for all interfaces.
327The primary interface may be replaced with another interface with the
328.Fl I
329option.
330The first line of each screen of information contains a summary since the
331system was last rebooted.
332Subsequent lines of output show values accumulated over the preceding interval.
333.Sh SEE ALSO
334.Xr nfsstat 1 ,
335.Xr ps 1 ,
336.Xr netintro 4 ,
337.Xr hosts 5 ,
338.Xr networks 5 ,
339.Xr protocols 5 ,
340.Xr services 5 ,
341.Xr iostat 8 ,
342.Xr trpt 8 ,
343.Xr trsp 8 ,
344.Xr vmstat 8
345.Sh HISTORY
346The
347.Nm
348command appeared in
349.Bx 4.2 .
350IPv6 support was added by WIDE/KAME project.
351.\" .Sh FILES
352.\" .Bl -tag -width /dev/kmem -compact
353.\" .It Pa /bsd
354.\" default kernel namelist
355.\" .It Pa /dev/kmem
356.\" default memory file
357.\" .El
358.Sh BUGS
359The notion of errors is ill-defined.
360