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