xref: /freebsd/usr.bin/netstat/netstat.1 (revision 5ff829fdbfd0f4c7e2dda5bd8a3aa1b928b1b18d)
1.\" Copyright (c) 1983, 1990, 1992, 1993
2.\"	The Regents of the University of California.  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.\"	@(#)netstat.1	8.8 (Berkeley) 4/18/94
33.\" $FreeBSD$
34.\"
35.Dd April 18, 1994
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 Fl M Ar core
46.Op Fl N Ar system
47.Nm netstat
48.Op Fl bdghimnrs
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 bdn
54.Op Fl I 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.
91With the routing table display (option
92.Fl r
93, as described below), show protocol-cloned routes (routes
94generated by a RTF_PRCLONING parent route); normally these routes are
95not shown.
96.It Fl b
97With the interface display (option
98.Fl i
99, as described below),
100show the number of bytes 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 ipx ,
116for
117.Dv AF_IPX  ,
118.Ar atalk ,
119for
120.Dv AF_APPLETALK (ddp)  ,
121.\".Ar ns ,
122.\"for
123.\".Dv AF_NS  ,
124.\".Ar iso ,
125.\"for
126.\".Dv AF_ISO ,
127and
128.Ar unix  ,
129for
130.Dv AF_UNIX  .
131.It Fl g
132Show information related to multicast (group address) routing.
133By default, show the IP Multicast virtual-interface and routing tables.
134If the
135.Fl s
136option is also present, show multicast routing statistics.
137.It Fl h
138Show the state of the
139.Tn IMP
140host table (obsolete).
141.It Fl I Ar interface
142Show information about the specified interface;
143used with a
144.Ar wait
145interval as described below.
146.It Fl i
147Show the state of interfaces which have been auto-configured
148(interfaces statically configured into a system, but not
149located at boot time are not shown).
150If the
151.Fl a
152options is also present, multicast addresses currently in use are shown
153for each Ethernet interface and for each IP interface address.
154Multicast addresses are shown on separate lines following the interface
155address with which they are associated.
156.It Fl M
157Extract values associated with the name list from the specified core
158instead of the default
159.Pa /dev/kmem .
160.It Fl m
161Show statistics recorded by the memory management routines
162(the network manages a private pool of memory buffers).
163.It Fl N
164Extract the name list from the specified system instead of the default
165.Pa /kernel .
166.It Fl n
167Show network addresses as numbers (normally
168.Nm netstat
169interprets addresses and attempts to display them
170symbolically).
171This option may be used with any of the display formats.
172.It Fl p Ar protocol
173Show statistics about
174.Ar protocol  ,
175which is either a well-known name for a protocol or an alias for it.  Some
176protocol names and aliases are listed in the file
177.Pa /etc/protocols .
178The special protocol name ``bdg''
179is used to show bridging statistics.
180A null response typically means that there are no interesting numbers to
181report.
182The program will complain if
183.Ar protocol
184is unknown or if there is no statistics routine for it.
185.It Fl s
186Show per-protocol statistics.
187If this option is repeated, counters with a value of zero are suppressed.
188.It Fl r
189Show the routing tables.
190Use with
191.Fl a
192to show protocol-cloned routes.
193When
194.Fl s
195is also present, show routing statistics instead.
196.It Fl w Ar wait
197Show network interface statistics at intervals of
198.Ar wait
199seconds.
200.El
201.Pp
202The default display, for active sockets, shows the local
203and remote addresses, send and receive queue sizes (in bytes), protocol,
204and the internal state of the protocol.
205Address formats are of the form ``host.port'' or ``network.port''
206if a socket's address specifies a network but no specific host address.
207When known the host and network addresses are displayed symbolically
208according to the data bases
209.Pa /etc/hosts
210and
211.Pa /etc/networks ,
212respectively.  If a symbolic name for an address is unknown, or if
213the
214.Fl n
215option is specified, the address is printed numerically, according
216to the address family.
217For more information regarding
218the Internet ``dot format,''
219refer to
220.Xr inet 3 ) .
221Unspecified,
222or ``wildcard'', addresses and ports appear as ``*''.
223.Pp
224The interface display provides a table of cumulative
225statistics regarding packets transferred, errors, and collisions.
226The network addresses of the interface
227and the maximum transmission unit (``mtu'') are also displayed.
228.Pp
229The routing table display indicates the available routes and
230their status.  Each route consists of a destination host or network
231and a gateway to use in forwarding packets.  The flags field shows
232a collection of information about the route stored as
233binary choices.  The individual flags are discussed in more
234detail in the
235.Xr route 8
236and
237.Xr route 4
238manual pages.
239The mapping between letters and flags is:
240.Bl -column XXXX RTF_BLACKHOLE
2411	RTF_PROTO1	Protocol specific routing flag #1
2422	RTF_PROTO2	Protocol specific routing flag #2
2433	RTF_PROTO3	Protocol specific routing flag #3
244B	RTF_BLACKHOLE	Just discard pkts (during updates)
245b	RTF_BROADCAST	The route represents a broadcast address
246C	RTF_CLONING	Generate new routes on use
247c	RTF_PRCLONING	Protocol-specified generate new routes on use
248D	RTF_DYNAMIC	Created dynamically (by redirect)
249G	RTF_GATEWAY	Destination requires forwarding by intermediary
250H	RTF_HOST	Host entry (net otherwise)
251L	RTF_LLINFO	Valid protocol to link address translation
252M	RTF_MODIFIED	Modified dynamically (by redirect)
253R	RTF_REJECT	Host or net unreachable
254S	RTF_STATIC	Manually added
255U	RTF_UP	Route usable
256W	RTF_WASCLONED	Route was generated as a result of cloning
257X	RTF_XRESOLVE	External daemon translates proto to link address
258.El
259.Pp
260Direct routes are created for each
261interface attached to the local host;
262the gateway field for such entries shows the address of the outgoing interface.
263The refcnt field gives the
264current number of active uses of the route.  Connection oriented
265protocols normally hold on to a single route for the duration of
266a connection while connectionless protocols obtain a route while sending
267to the same destination.
268The use field provides a count of the number of packets
269sent using that route.  The interface entry indicates the network
270interface utilized for the route.
271.Pp
272When
273.Nm netstat
274is invoked with the
275.Fl w
276option and a
277.Ar wait
278interval argument, it displays a running count of statistics related to
279network interfaces.
280An obsolescent version of this option used a numeric parameter
281with no option, and is currently supported for backward compatibility.
282By default, this display summarizes information for all interfaces.
283Information for a specific interface may be displayed with the
284.Fl I
285option.
286.Sh SEE ALSO
287.Xr fstat 1 ,
288.Xr nfsstat 1 ,
289.Xr sockstat 1 ,
290.Xr ps 1 ,
291.Xr inet 4 ,
292.Xr unix 4 ,
293.Xr hosts 5 ,
294.Xr networks 5 ,
295.Xr protocols 5 ,
296.Xr services 5 ,
297.Xr iostat 8 ,
298.Xr trpt 8 ,
299.Xr vmstat 8
300.Sh HISTORY
301The
302.Nm netstat
303command appeared in
304.Bx 4.2 .
305.\" .Sh FILES
306.\" .Bl -tag -width /dev/kmem -compact
307.\" .It Pa /kernel
308.\" default kernel namelist
309.\" .It Pa /dev/kmem
310.\" default memory file
311.\" .El
312.Sh BUGS
313The notion of errors is ill-defined.
314