xref: /netbsd-src/usr.bin/netstat/netstat.1 (revision 5f7096188587a2c7c95fa3c69b78e1ec9c7923d0)
1.\" Copyright (c) 1983, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	from: @(#)netstat.1	6.14 (Berkeley) 7/27/91
33.\"	$Id: netstat.1,v 1.2 1993/08/01 07:30:27 mycroft Exp $
34.\"
35.Dd July 27, 1991
36.Dt NETSTAT 1
37.Os BSD 4.2
38.Sh NAME
39.Nm netstat
40.Nd show network status
41.Sh SYNOPSIS
42.Nm netstat
43.Op Fl Aan
44.Op Fl f Ar address_family
45.Op Ar system
46.Op Ar core
47.Nm netstat
48.Op Fl himnrs
49.Op Fl f Ar address_family
50.Op Fl M Ar core
51.Op Fl N Ar system
52.Nm netstat
53.Op Fl n
54.Op Fl I Op Ar interface
55.Op Fl M Ar core
56.Op Fl N Ar system
57.Op Fl w Ar wait
58.Nm netstat
59.Op Fl p Ar protocol
60.Op Fl M Ar core
61.Op Fl N Ar system
62.Sh DESCRIPTION
63The
64.Nm netstat
65command symbolically displays the contents of various network-related
66data structures.
67There are a number of output formats,
68depending on the options for the information presented.
69The first form of the command displays a list of active sockets for
70each protocol.
71The second form presents the contents of one of the other network
72data structures according to the option selected.
73Using the third form, with a
74.Ar wait
75interval specified,
76.Nm netstat
77will continuously display the information regarding packet
78traffic on the configured network interfaces.
79The fourth form displays statistics about the named protocol.
80.Pp
81The options have the following meaning:
82.Bl -tag -width flag
83.It Fl A
84With the default display,
85show the address of any protocol control blocks associated with sockets; used
86for debugging.
87.It Fl a
88With the default display,
89show the state of all sockets; normally sockets used by
90server processes are not shown.
91.It Fl d
92With either interface display (option
93.Fl i
94or an interval, as described below),
95show the number of dropped packets.
96.It Fl h
97Show the state of the
98.Tn IMP
99host table.
100.It Fl i
101Show the state of interfaces which have been auto-configured
102(interfaces statically configured into a system, but not
103located at boot time are not shown).
104.It Fl I Ar interface
105Show information only about this interface;
106used with an
107.Ar wait
108interval as described below.
109.It Fl M
110Extract values associated with the name list from the specified core
111instead of the default
112.Pa /dev/kmem .
113.It Fl m
114Show statistics recorded by the memory management routines
115(the network manages a private pool of memory buffers).
116.It Fl N
117Extract the name list from the specified system instead of the default
118.Pa /vmunix .
119.It Fl n
120Show network addresses as numbers (normally
121.Nm netstat
122interprets addresses and attempts to display them
123symbolically).
124This option may be used with any of the display formats.
125.It Fl p Ar protocol
126Show statistics about
127.Ar protocol  ,
128which is either a well-known name for a protocol or an alias for it.  Some
129protocol names and aliases are listed in the file
130.Pa /etc/protocols .
131A null response typically means that there are no interesting numbers to
132report.
133The program will complain if
134.Ar protocol
135is unknown or if there is no statistics routine for it.
136.It Fl s
137Show per-protocol statistics.
138.It Fl r
139Show the routing tables.
140When
141.Fl s
142is also present, show routing statistics instead.
143.It Fl f Ar address_family
144Limit statistics or address control block reports to those
145of the specified
146.Ar address family  .
147The following address families
148are recognized:
149.Ar inet  ,
150for
151.Dv AF_INET  ,
152.Ar ns ,
153for
154.Dv AF_NS  ,
155and
156.Ar unix  ,
157for
158.Dv AF_UNIX  .
159.El
160.Pp
161The default display, for active sockets, shows the local
162and remote addresses, send and receive queue sizes (in bytes), protocol,
163and the internal state of the protocol.
164Address formats are of the form ``host.port'' or ``network.port''
165if a socket's address specifies a network but no specific host address.
166When known the host and network addresses are displayed symbolically
167according to the data bases
168.Pa /etc/hosts
169and
170.Pa /etc/networks ,
171respectively.  If a symbolic name for an address is unknown, or if
172the
173.Fl n
174option is specified, the address is printed numerically, according
175to the address family.
176For more information regarding
177the Internet ``dot format,''
178refer to
179.Xr inet 3 ) .
180Unspecified,
181or ``wildcard'', addresses and ports appear as ``*''.
182.Pp
183The interface display provides a table of cumulative
184statistics regarding packets transferred, errors, and collisions.
185The network addresses of the interface
186and the maximum transmission unit (``mtu'') are also displayed.
187.Pp
188The routing table display indicates the available routes and
189their status.  Each route consists of a destination host or network
190and a gateway to use in forwarding packets.  The flags field shows
191the state of the route (``U'' if ``up''), whether the route
192is to a gateway (``G''), whether the route was created dynamically
193by a redirect (``D''), and whether the route has been modified
194by a redirect (``M'').  Direct routes are created for each
195interface attached to the local host;
196the gateway field for such entries shows the address of the outgoing interface.
197The refcnt field gives the
198current number of active uses of the route.  Connection oriented
199protocols normally hold on to a single route for the duration of
200a connection while connectionless protocols obtain a route while sending
201to the same destination.
202The use field provides a count of the number of packets
203sent using that route.  The interface entry indicates the network
204interface utilized for the route.
205.Pp
206When
207.Nm netstat
208is invoked with a
209.Ar wait
210interval argument, it displays a running count of statistics related to
211network interfaces.
212This display consists of a column for the primary interface (the first
213interface found during autoconfiguration) and a column summarizing
214information for all interfaces.
215The primary interface may be replaced with another interface with the
216.Fl I
217option.
218The first line of each screen of information contains a summary since the
219system was last rebooted.  Subsequent lines of output show values
220accumulated over the preceding interval.
221.Sh SEE ALSO
222.Xr iostat 1 ,
223.Xr nfsstat 1 ,
224.Xr ps 1 ,
225.Xr vmstat 1 ,
226.Xr hosts 5 ,
227.Xr networks 5 ,
228.Xr protocols 5 ,
229.Xr services 5 ,
230.Xr trpt 8 ,
231.Xr trsp 8
232.Sh HISTORY
233The
234.Nm netstat
235command appeared in
236.Bx 4.2 .
237.\" .Sh FILES
238.\" .Bl -tag -width /dev/kmem -compact
239.\" .It Pa /vmunix
240.\" default kernel namelist
241.\" .It Pa /dev/kmem
242.\" default memory file
243.\" .El
244.Sh BUGS
245The notion of errors is ill-defined.
246.Pp
247Collisions mean something else for the
248.Tn IMP .
249