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