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