xref: /freebsd/usr.bin/netstat/netstat.1 (revision 409a390c3341fb4f162cd7de1fd595a323ebbfd8)
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 January 10, 2010
36.Dt NETSTAT 1
37.Os
38.Sh NAME
39.Nm netstat
40.Nd show network status
41.Sh DESCRIPTION
42The
43.Nm
44command symbolically displays the contents of various network-related
45data structures.
46There are a number of output formats,
47depending on the options for the information presented.
48.Bl -tag -width indent
49.It Xo
50.Bk -words
51.Nm
52.Op Fl AaLnSWx
53.Op Fl f Ar protocol_family | Fl p Ar protocol
54.Op Fl M Ar core
55.Op Fl N Ar system
56.Ek
57.Xc
58Display a list of active sockets
59(protocol control blocks)
60for each network protocol,
61for a particular
62.Ar protocol_family ,
63or for a single
64.Ar protocol .
65If
66.Fl A
67is also present,
68show the address of a protocol control block (PCB)
69associated with a socket; used for debugging.
70If
71.Fl a
72is also present,
73show the state of all sockets;
74normally sockets used by server processes are not shown.
75If
76.Fl L
77is also present,
78show the size of the various listen queues.
79The first count shows the number of unaccepted connections,
80the second count shows the amount of unaccepted incomplete connections,
81and the third count is the maximum number of queued connections.
82If
83.Fl S
84is also present,
85show network addresses as numbers (as with
86.Fl n )
87but show ports symbolically.
88If
89.Fl x
90is present, display socket buffer and tcp timer statistics for each internet socket.
91.It Xo
92.Bk -words
93.Nm
94.Fl i | I Ar interface
95.Op Fl abdhnW
96.Op Fl f Ar address_family
97.Op Fl M Ar core
98.Op Fl N Ar system
99.Ek
100.Xc
101Show the state of all network interfaces or a single
102.Ar interface
103which have been auto-configured
104(interfaces statically configured into a system, but not
105located at boot time are not shown).
106An asterisk
107.Pq Dq Li *
108after an interface name indicates that the interface is
109.Dq down .
110If
111.Fl a
112is also present, multicast addresses currently in use are shown
113for each Ethernet interface and for each IP interface address.
114Multicast addresses are shown on separate lines following the interface
115address with which they are associated.
116If
117.Fl b
118is also present, show the number of bytes in and out.
119If
120.Fl d
121is also present, show the number of dropped packets.
122If
123.Fl h
124is also present, print all counters in human readable form.
125If
126.Fl W
127is also present, print interface names using a wider field size.
128.It Xo
129.Bk -words
130.Nm
131.Fl w Ar wait
132.Op Fl I Ar interface
133.Op Fl d
134.Op Fl M Ar core
135.Op Fl N Ar system
136.Op Fl q Ar howmany
137.Ek
138.Xc
139At intervals of
140.Ar wait
141seconds,
142display the information regarding packet
143traffic on all configured network interfaces
144or a single
145.Ar interface .
146If
147.Fl q
148is also present, exit after
149.Ar howmany
150outputs.
151If
152.Fl d
153is also present, show the number of dropped packets.
154.It Xo
155.Bk -words
156.Nm
157.Fl s Op Fl s
158.Op Fl z
159.Op Fl f Ar protocol_family | Fl p Ar protocol
160.Op Fl M Ar core
161.Op Fl N Ar system
162.Ek
163.Xc
164Display system-wide statistics for each network protocol,
165for a particular
166.Ar protocol_family ,
167or for a single
168.Ar protocol .
169If
170.Fl s
171is repeated, counters with a value of zero are suppressed.
172If
173.Fl z
174is also present, reset statistic counters after displaying them.
175.It Xo
176.Bk -words
177.Nm
178.Fl i | I Ar interface Fl s
179.Op Fl f Ar protocol_family | Fl p Ar protocol
180.Op Fl M Ar core
181.Op Fl N Ar system
182.Ek
183.Xc
184Display per-interface statistics for each network protocol,
185for a particular
186.Ar protocol_family ,
187or for a single
188.Ar protocol .
189.It Xo
190.Bk -words
191.Nm
192.Fl m
193.Op Fl M Ar core
194.Op Fl N Ar system
195.Ek
196.Xc
197Show statistics recorded by the memory management routines
198.Pq Xr mbuf 9 .
199The network manages a private pool of memory buffers.
200.It Xo
201.Bk -words
202.Nm
203.Fl B
204.Op Fl z
205.Op Fl I Ar interface
206.Ek
207.Xc
208Show statistics about
209.Xr bpf 4
210peers.
211This includes information like
212how many packets have been matched, dropped and received by the
213bpf device, also information about current buffer sizes and device
214states.
215.It Xo
216.Bk -words
217.Nm
218.Fl r
219.Op Fl AanW
220.Op Fl f Ar address_family
221.Op Fl M Ar core
222.Op Fl N Ar system
223.Ek
224.Xc
225Display the contents of all routing tables,
226or a routing table for a particular
227.Ar address_family .
228If
229.Fl A
230is also present,
231show the contents of the internal Patricia tree
232structures; used for debugging.
233If
234.Fl a
235is also present,
236show protocol-cloned routes
237(routes generated by an
238.Dv RTF_PRCLONING
239parent route);
240normally these routes are not shown.
241When
242.Fl W
243is also present,
244show the path MTU
245for each route,
246and print interface
247names with a wider
248field size.
249.It Xo
250.Bk -words
251.Nm
252.Fl rs
253.Op Fl s
254.Op Fl M Ar core
255.Op Fl N Ar system
256.Ek
257.Xc
258Display routing statistics.
259If
260.Fl s
261is repeated, counters with a value of zero are suppressed.
262.It Xo
263.Bk -words
264.Nm
265.Fl g
266.Op Fl W
267.Op Fl f Ar address_family
268.Op Fl M Ar core
269.Op Fl N Ar system
270.Ek
271.Xc
272Display the contents of the multicast virtual interface tables,
273and multicast forwarding caches.
274Entries in these tables will appear only when the kernel is
275actively forwarding multicast sessions.
276This option is applicable only to the
277.Cm inet
278and
279.Cm inet6
280address families.
281.It Xo
282.Bk -words
283.Nm
284.Fl gs
285.Op Fl s
286.Op Fl f Ar address_family
287.Op Fl M Ar core
288.Op Fl N Ar system
289.Ek
290.Xc
291Show multicast routing statistics.
292If
293.Fl s
294is repeated, counters with a value of zero are suppressed.
295.El
296.Pp
297Some options have the general meaning:
298.Bl -tag -width flag
299.It Fl f Ar address_family , Fl p Ar protocol
300Limit display to those records
301of the specified
302.Ar address_family
303or a single
304.Ar protocol .
305The following address families and protocols are recognized:
306.Pp
307.Bl -tag -width ".Cm netgraph , ng Pq Dv AF_NETGRAPH" -compact
308.It Em Family
309.Em Protocols
310.It Cm inet Pq Dv AF_INET
311.Cm divert , icmp , igmp , ip , ipsec , pim, sctp , tcp , udp
312.It Cm inet6 Pq Dv AF_INET6
313.Cm icmp6 , ip6 , ipsec6 , rip6 , tcp , udp
314.It Cm pfkey Pq Dv PF_KEY
315.Cm pfkey
316.It Cm atalk Pq Dv AF_APPLETALK
317.Cm ddp
318.It Cm netgraph , ng Pq Dv AF_NETGRAPH
319.Cm ctrl , data
320.It Cm ipx Pq Dv AF_IPX
321.Cm ipx , spx
322.\".It Cm ns Pq Dv AF_NS
323.\".Cm idp , ns_err , spp
324.\".It Cm iso Pq Dv AF_ISO
325.\".Cm clnp , cltp , esis , tp
326.It Cm unix Pq Dv AF_UNIX
327.It Cm link Pq Dv AF_LINK
328.El
329.Pp
330The program will complain if
331.Ar protocol
332is unknown or if there is no statistics routine for it.
333.It Fl M
334Extract values associated with the name list from the specified core
335instead of the default
336.Pa /dev/kmem .
337.It Fl N
338Extract the name list from the specified system instead of the default,
339which is the kernel image the system has booted from.
340.It Fl n
341Show network addresses and ports as numbers.
342Normally
343.Nm
344attempts to resolve addresses and ports,
345and display them symbolically.
346.It Fl W
347In certain displays, avoid truncating addresses even if this causes
348some fields to overflow.
349.El
350.Pp
351The default display, for active sockets, shows the local
352and remote addresses, send and receive queue sizes (in bytes), protocol,
353and the internal state of the protocol.
354Address formats are of the form
355.Dq host.port
356or
357.Dq network.port
358if a socket's address specifies a network but no specific host address.
359When known, the host and network addresses are displayed symbolically
360according to the databases
361.Xr hosts 5
362and
363.Xr networks 5 ,
364respectively.
365If a symbolic name for an address is unknown, or if
366the
367.Fl n
368option is specified, the address is printed numerically, according
369to the address family.
370For more information regarding
371the Internet IPv4
372.Dq dot format ,
373refer to
374.Xr inet 3 .
375Unspecified,
376or
377.Dq wildcard ,
378addresses and ports appear as
379.Dq Li * .
380.Pp
381The interface display provides a table of cumulative
382statistics regarding packets transferred, errors, and collisions.
383The network addresses of the interface
384and the maximum transmission unit
385.Pq Dq mtu
386are also displayed.
387.Pp
388The routing table display indicates the available routes and their status.
389Each route consists of a destination host or network, and a gateway to use
390in forwarding packets.
391The flags field shows a collection of information about the route stored
392as binary choices.
393The individual flags are discussed in more detail in the
394.Xr route 8
395and
396.Xr route 4
397manual pages.
398The mapping between letters and flags is:
399.Bl -column ".Li W" ".Dv RTF_WASCLONED"
400.It Li 1 Ta Dv RTF_PROTO1 Ta "Protocol specific routing flag #1"
401.It Li 2 Ta Dv RTF_PROTO2 Ta "Protocol specific routing flag #2"
402.It Li 3 Ta Dv RTF_PROTO3 Ta "Protocol specific routing flag #3"
403.It Li B Ta Dv RTF_BLACKHOLE Ta "Just discard pkts (during updates)"
404.It Li b Ta Dv RTF_BROADCAST Ta "The route represents a broadcast address"
405.It Li C Ta Dv RTF_CLONING Ta "Generate new routes on use"
406.It Li c Ta Dv RTF_PRCLONING Ta "Protocol-specified generate new routes on use"
407.It Li D Ta Dv RTF_DYNAMIC Ta "Created dynamically (by redirect)"
408.It Li G Ta Dv RTF_GATEWAY Ta "Destination requires forwarding by intermediary"
409.It Li H Ta Dv RTF_HOST Ta "Host entry (net otherwise)"
410.It Li L Ta Dv RTF_LLINFO Ta "Valid protocol to link address translation"
411.It Li M Ta Dv RTF_MODIFIED Ta "Modified dynamically (by redirect)"
412.It Li R Ta Dv RTF_REJECT Ta "Host or net unreachable"
413.It Li S Ta Dv RTF_STATIC Ta "Manually added"
414.It Li U Ta Dv RTF_UP Ta "Route usable"
415.It Li W Ta Dv RTF_WASCLONED Ta "Route was generated as a result of cloning"
416.It Li X Ta Dv RTF_XRESOLVE Ta "External daemon translates proto to link address"
417.El
418.Pp
419Direct routes are created for each
420interface attached to the local host;
421the gateway field for such entries shows the address of the outgoing interface.
422The refcnt field gives the
423current number of active uses of the route.
424Connection oriented
425protocols normally hold on to a single route for the duration of
426a connection while connectionless protocols obtain a route while sending
427to the same destination.
428The use field provides a count of the number of packets
429sent using that route.
430The interface entry indicates the network interface utilized for the route.
431.Pp
432When
433.Nm
434is invoked with the
435.Fl w
436option and a
437.Ar wait
438interval argument, it displays a running count of statistics related to
439network interfaces.
440An obsolescent version of this option used a numeric parameter
441with no option, and is currently supported for backward compatibility.
442By default, this display summarizes information for all interfaces.
443Information for a specific interface may be displayed with the
444.Fl I
445option.
446.Pp
447The
448.Xr bpf 4
449flags displayed when
450.Nm
451is invoked with the
452.Fl B
453option represent the underlying parameters of the bpf peer.
454Each flag is
455represented as a single lower case letter.
456The mapping between the letters and flags in order of appearance are:
457.Bl -column ".Li i"
458.It Li p Ta Set if listening promiscuously
459.It Li i Ta Dv BIOCIMMEDIATE No has been set on the device
460.It Li f Ta Dv BIOCGHDRCMPLT No status: source link addresses are being
461filled automatically
462.It Li s Ta Dv BIOCGSEESENT No status: see packets originating locally and
463remotely on the interface.
464.It Li a Ta Packet reception generates a signal
465.It Li l Ta Dv BIOCLOCK No status: descriptor has been locked
466.El
467.Pp
468For more information about these flags, please refer to
469.Xr bpf 4 .
470.Pp
471The
472.Fl x
473flag causes
474.Nm
475to output all the information recorded about data
476stored in the socket buffers.
477The fields are:
478.Bl -column ".Li R-MBUF"
479.It Li R-MBUF Ta Number of mbufs in the receive queue.
480.It Li S-MBUF Ta Number of mbufs in the send queue.
481.It Li R-CLUS Ta Number of clusters, of any type, in the receive
482queue.
483.It Li S-CLUS Ta Number of clusters, of any type, in the send queue.
484.It Li R-HIWA Ta Receive buffer high water mark, in bytes.
485.It Li S-HIWA Ta Send buffer high water mark, in bytes.
486.It Li R-LOWA Ta Receive buffer low water mark, in bytes.
487.It Li S-LOWA Ta Send buffer low water mark, in bytes.
488.It Li R-BCNT Ta Receive buffer byte count.
489.It Li S-BCNT Ta Send buffer byte count.
490.It Li R-BMAX Ta Maximum bytes that can be used in the receive buffer.
491.It Li S-BMAX Ta Maximum bytes that can be used in the send buffer.
492.El
493.Sh SEE ALSO
494.Xr fstat 1 ,
495.Xr nfsstat 1 ,
496.Xr procstat 1 ,
497.Xr ps 1 ,
498.Xr sockstat 1 ,
499.Xr bpf 4 ,
500.Xr inet 4 ,
501.Xr route 4 ,
502.Xr unix 4 ,
503.Xr hosts 5 ,
504.Xr networks 5 ,
505.Xr protocols 5 ,
506.Xr services 5 ,
507.Xr iostat 8 ,
508.Xr route 8 ,
509.Xr trpt 8 ,
510.Xr vmstat 8 ,
511.Xr mbuf 9
512.Sh HISTORY
513The
514.Nm
515command appeared in
516.Bx 4.2 .
517.Pp
518IPv6 support was added by WIDE/KAME project.
519.Sh BUGS
520The notion of errors is ill-defined.
521