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