xref: /netbsd-src/usr.bin/netstat/netstat.1 (revision bada23909e740596d0a3785a73bd3583a9807fb8)
1.\"	$NetBSD: netstat.1,v 1.20 1999/03/14 18:30:04 kristerw 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 BSD 4.2
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 dgimnrsv
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.Sh DESCRIPTION
69The
70.Nm
71command symbolically displays the contents of various network-related
72data structures.
73There are a number of output formats,
74depending on the options for the information presented.
75The first form of the command displays a list of active sockets for
76each protocol.
77The second form presents the contents of one of the other network
78data structures according to the option selected.
79Using the third form, with a
80.Ar wait
81interval specified,
82.Nm
83will continuously display the information regarding packet
84traffic on the configured network interfaces.
85The fourth form displays statistics about the named protocol.
86.Pp
87The options have the following meaning:
88.Bl -tag -width flag
89.It Fl A
90With the default display,
91show the address of any protocol control blocks associated with sockets; used
92for debugging.
93.It Fl a
94With the default display,
95show the state of all sockets; normally sockets used by
96server processes are not shown.
97.It Fl b
98With the interface display (option
99.Fl i ) ,
100show bytes in and out, instead of packets in and out.
101.It Fl d
102With either interface display (option
103.Fl i
104or an interval, as described below),
105show the number of dropped packets.
106.It Fl f Ar address_family
107Limit statistics or address control block reports to those
108of the specified
109.Ar address family  .
110The following address families
111are recognized:
112.Ar inet ,
113for
114.Dv AF_INET ;
115.Ar ns ,
116for
117.Dv AF_NS ;
118.Ar iso ,
119for
120.Dv AF_ISO ;
121.Ar atalk ,
122for
123.Dv AF_APPLETALK ;
124and
125.Ar local
126or
127.Ar unix ,
128for
129.Dv AF_LOCAL .
130.It Fl g
131Show information related to multicast (group address) routing.
132By default, show the IP Multicast virtual-interface and routing tables.
133If the
134.Fl s
135option is also present, show multicast routing statistics.
136.It Fl I Ar interface
137Show information about the specified interface;
138used with a
139.Ar wait
140interval as described below.
141.It Fl i
142Show the state of interfaces which have been auto-configured
143(interfaces statically configured into a system, but not
144located at boot time are not shown).
145If the
146.Fl a
147options is also present, multicast addresses currently in use are shown
148for each Ethernet interface and for each IP interface address.
149Multicast addresses are shown on separate lines following the interface
150address with which they are associated.
151.It Fl M
152Extract values associated with the name list from the specified core
153instead of the default
154.Pa /dev/kmem .
155.It Fl m
156Show statistics recorded by the memory management routines
157(the network manages a private pool of memory buffers).
158.It Fl N
159Extract the name list from the specified system instead of the default
160.Pa /netbsd .
161.It Fl n
162Show network addresses as numbers (normally
163.Nm
164interprets addresses and attempts to display them
165symbolically).
166This option may be used with any of the display formats.
167.It Fl P Ar pcbaddr
168Dump the contents of the protocol control block (PCB) located at kernel
169virtual address
170.Ar pcbaddr .
171This address may be obtained using the
172.Fl A
173flag.  The default protocol is TCP, but may be overridden using the
174.Fl p
175flag.
176.It Fl p Ar protocol
177Show statistics about
178.Ar protocol  ,
179which is either a well-known name for a protocol or an alias for it.  Some
180protocol names and aliases are listed in the file
181.Pa /etc/protocols .
182A null response typically means that there are no interesting numbers to
183report.
184The program will complain if
185.Ar protocol
186is unknown or if there is no statistics routine for it.
187.It Fl s
188Show per-protocol statistics.
189If this option is repeated, counters with a value of zero are suppressed.
190.It Fl r
191Show the routing tables.
192When
193.Fl s
194is also present, show routing statistics instead.
195.It Fl v
196Show extra (verbose) detail for the routing tables.
197.It Fl w Ar wait
198Show network interface statistics at intervals of
199.Ar wait
200seconds.
201.El
202.Pp
203The default display, for active sockets, shows the local
204and remote addresses, send and receive queue sizes (in bytes), protocol,
205and the internal state of the protocol.
206Address formats are of the form ``host.port'' or ``network.port''
207if a socket's address specifies a network but no specific host address.
208When known the host and network addresses are displayed symbolically
209according to the data bases
210.Pa /etc/hosts
211and
212.Pa /etc/networks ,
213respectively.  If a symbolic name for an address is unknown, or if
214the
215.Fl n
216option is specified, the address is printed numerically, according
217to the address family.
218For more information regarding
219the Internet ``dot format,''
220refer to
221.Xr inet 3 ) .
222Unspecified,
223or ``wildcard'', addresses and ports appear as ``*''.
224.Pp
225The interface display provides a table of cumulative
226statistics regarding packets transferred, errors, and collisions.
227The network addresses of the interface
228and the maximum transmission unit (``mtu'') are also displayed.
229.Pp
230The routing table display indicates the available routes and
231their status.  Each route consists of a destination host or network
232and a gateway to use in forwarding packets.  The flags field shows
233a collection of information about the route stored as
234binary choices.  The individual flags are discussed in more
235detail in the
236.Xr route 8
237and
238.Xr route 4
239manual pages.
240The mapping between letters and flags is:
241.Bl -column XXXX RTF_BLACKHOLE
2421	RTF_PROTO2	Protocol specific routing flag #1
2432	RTF_PROTO1	Protocol specific routing flag #2
244B	RTF_BLACKHOLE	Just discard pkts (during updates)
245C	RTF_CLONING	Generate new routes on use
246D	RTF_DYNAMIC	Created dynamically (by redirect)
247G	RTF_GATEWAY	Destination requires forwarding by intermediary
248H	RTF_HOST	Host entry (net otherwise)
249L	RTF_LLINFO	Valid protocol to link address translation.
250M	RTF_MODIFIED	Modified dynamically (by redirect)
251R	RTF_REJECT	Host or net unreachable
252S	RTF_STATIC	Manually added
253U	RTF_UP	Route usable
254X	RTF_XRESOLVE	External daemon translates proto to link address
255.El
256.Pp
257Direct routes are created for each
258interface attached to the local host;
259the gateway field for such entries shows the address of the outgoing interface.
260The refcnt field gives the
261current number of active uses of the route.  Connection oriented
262protocols normally hold on to a single route for the duration of
263a connection while connectionless protocols obtain a route while sending
264to the same destination.
265The use field provides a count of the number of packets
266sent using that route.  The mtu entry shows the mtu associated with
267that route.  This mtu value is used as the basis for the TCP maximum
268segment size.  The 'L' flag appended to the mtu value indicates that
269the value is locked, and that path mtu discovery is turned off for
270that route.
271A
272.Sq -
273indicates that the mtu for this route has not been set, and a default
274TCP maximum segment size will be used.  The interface entry indicates
275the network interface utilized for the route.
276.Pp
277When
278.Nm
279is invoked with the
280.Fl w
281option and a
282.Ar wait
283interval argument, it displays a running count of statistics related to
284network interfaces.
285An obsolescent version of this option used a numeric parameter
286with no option, and is currently supported for backward compatibility.
287This display consists of a column for the primary interface (the first
288interface found during autoconfiguration) and a column summarizing
289information for all interfaces.
290The primary interface may be replaced with another interface with the
291.Fl I
292option.
293The first line of each screen of information contains a summary since the
294system was last rebooted.  Subsequent lines of output show values
295accumulated over the preceding interval.
296.Sh SEE ALSO
297.Xr nfsstat 1 ,
298.Xr ps 1 ,
299.Xr hosts 5 ,
300.Xr networks 5 ,
301.Xr protocols 5 ,
302.Xr services 5 ,
303.Xr trpt 8 ,
304.Xr trsp 8 ,
305.Xr iostat 8 ,
306.Xr vmstat 8
307.Sh HISTORY
308The
309.Nm
310command appeared in
311.Bx 4.2 .
312.\" .Sh FILES
313.\" .Bl -tag -width /dev/kmem -compact
314.\" .It Pa /netbsd
315.\" default kernel namelist
316.\" .It Pa /dev/kmem
317.\" default memory file
318.\" .El
319.Sh BUGS
320The notion of errors is ill-defined.
321