]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/netstat/netstat.1
zfs: merge openzfs/zfs@a0b2a93c4
[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 .\" 3. 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 .Dd August 14, 2023
29 .Dt NETSTAT 1
30 .Os
31 .Sh NAME
32 .Nm netstat
33 .Nd show network status and statistics
34 .Sh SYNOPSIS
35 .Bk -words
36 .Bl -tag -width "netstat"
37 .It Nm
38 .Op Fl j Ar jail
39 .Op Fl -libxo
40 .Op Fl 46AaCLnPRSTWx
41 .Op Fl f Ar protocol_family | Fl p Ar protocol
42 .It Nm Fl i | I Ar interface
43 .Op Fl j Ar jail
44 .Op Fl -libxo
45 .Op Fl 46abdhnW
46 .Op Fl f Ar address_family
47 .Op Fl M Ar core
48 .Op Fl N Ar system
49 .It Nm Fl w Ar wait
50 .Op Fl j Ar jail
51 .Op Fl -libxo
52 .Op Fl I Ar interface
53 .Op Fl 46d
54 .Op Fl M Ar core
55 .Op Fl N Ar system
56 .Op Fl q Ar howmany
57 .It Nm Fl s
58 .Op Fl j Ar jail
59 .Op Fl -libxo
60 .Op Fl 46sz
61 .Op Fl f Ar protocol_family | Fl p Ar protocol
62 .Op Fl M Ar core
63 .Op Fl N Ar system
64 .It Nm Fl i | I Ar interface Fl s
65 .Op Fl j Ar jail
66 .Op Fl -libxo
67 .Op Fl 46s
68 .Op Fl f Ar protocol_family | Fl p Ar protocol
69 .Op Fl M Ar core
70 .Op Fl N Ar system
71 .It Nm Fl m
72 .Op Fl j Ar jail
73 .Op Fl -libxo
74 .Op Fl M Ar core
75 .Op Fl N Ar system
76 .It Nm Fl B
77 .Op Fl j Ar jail
78 .Op Fl -libxo
79 .Op Fl z
80 .Op Fl I Ar interface
81 .It Nm Fl r
82 .Op Fl j Ar jail
83 .Op Fl -libxo
84 .Op Fl 46nW
85 .Op Fl F Ar fibnum
86 .Op Fl f Ar address_family
87 .It Nm Fl rs
88 .Op Fl j Ar jail
89 .Op Fl -libxo
90 .Op Fl s
91 .Op Fl M Ar core
92 .Op Fl N Ar system
93 .It Nm Fl g
94 .Op Fl j Ar jail
95 .Op Fl -libxo
96 .Op Fl 46W
97 .Op Fl f Ar address_family
98 .It Nm Fl gs
99 .Op Fl j Ar jail
100 .Op Fl -libxo
101 .Op Fl 46s
102 .Op Fl f Ar address_family
103 .Op Fl M Ar core
104 .Op Fl N Ar system
105 .It Nm Fl Q
106 .Op Fl j Ar jail
107 .Op Fl -libxo
108 .El
109 .Ek
110 .Sh DESCRIPTION
111 The
112 .Nm
113 command shows the contents of various network-related
114 data structures.
115 The arguments passed determine which of the below output formats the
116 command uses.
117 .Bl -tag -width indent
118 .It Xo
119 .Bk -words
120 .Nm
121 .Op Fl 46AaCLnRSTWx
122 .Op Fl f Ar protocol_family | Fl p Ar protocol
123 .Op Fl j Ar jail
124 .Ek
125 .Xc
126 Display a list of active sockets
127 (protocol control blocks)
128 for each network protocol.
129 .Pp
130 The default display for active sockets shows the local
131 and remote addresses, send and receive queue sizes (in bytes), protocol,
132 and the internal state of the protocol.
133 Address formats are of the form
134 .Dq host.port
135 or
136 .Dq network.port
137 if a socket's address specifies a network but no specific host address.
138 When known, the host and network addresses are displayed symbolically
139 according to the databases
140 .Xr hosts 5
141 and
142 .Xr networks 5 ,
143 respectively.
144 If a symbolic name for an address is unknown, or if
145 the
146 .Fl n
147 option is specified, the address is printed numerically, according
148 to the address family.
149 For more information regarding
150 the Internet IPv4
151 .Dq dot format ,
152 refer to
153 .Xr inet 3 .
154 Unspecified,
155 or
156 .Dq wildcard ,
157 addresses and ports appear as
158 .Dq Li * .
159 .Bl -tag -width indent
160 .It Fl -libxo
161 Generate output via
162 .Xr libxo 3
163 in a selection of different human and machine readable formats.
164 See
165 .Xr xo_parse_args 3
166 for details on command line arguments.
167 .It Fl 4
168 Show IPv4 only.
169 See
170 .Sx GENERAL OPTIONS .
171 .It Fl 6
172 Show IPv6 only.
173 See
174 .Sx GENERAL OPTIONS .
175 .It Fl A
176 Show the address of a protocol control block (PCB)
177 associated with a socket; used for debugging.
178 .It Fl a
179 Show the state of all sockets;
180 normally sockets used by server processes are not shown.
181 .It Fl c
182 Show the used TCP stack for each session.
183 .It Fl C
184 Show the congestion control algorithm and diagnostic information of TCP sockets.
185 .It Fl L
186 Show the size of the various listen queues.
187 The first count shows the number of unaccepted connections,
188 the second count shows the amount of unaccepted incomplete connections,
189 and the third count is the maximum number of queued connections.
190 .It Fl n
191 Do not resolve numeric addresses and port numbers to names.
192 See
193 .Sx GENERAL OPTIONS .
194 .It Fl P
195 Display the log ID for each socket.
196 .It Fl R
197 Display the flowid and flowtype for each socket.
198 flowid is a 32 bit hardware specific identifier for each flow.
199 flowtype defines which protocol fields are hashed to produce the id.
200 A complete listing is available in
201 .Pa sys/mbuf.h
202 under
203 .Dv M_HASHTYPE_* .
204 .It Fl S
205 Show network addresses as numbers (as with
206 .Fl n )
207 but show ports symbolically.
208 .It Fl T
209 Display diagnostic information from the TCP control block.
210 Fields include the number of packets requiring retransmission,
211 received out-of-order, and those advertising a zero-sized window.
212 .It Fl W
213 Avoid truncating addresses even if this causes some fields to overflow.
214 .It Fl x
215 Display socket buffer and TCP timer statistics for each
216 internet socket.
217 .Pp
218 The
219 .Fl x
220 flag causes
221 .Nm
222 to output all the information recorded about data
223 stored in the socket buffers.
224 The fields are:
225 .Bl -column ".Li R-HIWA"
226 .It Li R-HIWA Ta Receive buffer high water mark, in bytes.
227 .It Li S-HIWA Ta Send buffer high water mark, in bytes.
228 .It Li R-LOWA Ta Receive buffer low water mark, in bytes.
229 .It Li S-LOWA Ta Send buffer low water mark, in bytes.
230 .It Li R-BCNT Ta Receive buffer byte count.
231 .It Li S-BCNT Ta Send buffer byte count.
232 .It Li R-BMAX Ta Maximum bytes that can be used in the receive buffer.
233 .It Li S-BMAX Ta Maximum bytes that can be used in the send buffer.
234 .It Li rexmt Ta Time, in seconds, to fire Retransmit Timer, or 0 if not armed.
235 .It Li persist Ta Time, in seconds, to fire Retransmit Persistence, or 0 if not armed.
236 .It Li keep Ta Time, in seconds, to fire Keep Alive, or 0 if not armed.
237 .It Li 2msl Ta Time, in seconds, to fire 2*msl TIME_WAIT Timer, or 0 if not armed.
238 .It Li delack Ta Time, in seconds, to fire Delayed ACK Timer, or 0 if not armed.
239 .It Li rcvtime Ta Time, in seconds, since last packet received.
240 .El
241 .It Fl f Ar protocol_family
242 Filter by
243 .Ar protocol_family .
244 See
245 .Sx GENERAL OPTIONS .
246 .It Fl p Ar protocol
247 Filter by
248 .Ar protocol .
249 See
250 .Sx GENERAL OPTIONS .
251 .It Fl j Ar jail
252 Run inside a jail.
253 See
254 .Sx GENERAL OPTIONS .
255 .El
256 .It Xo
257 .Bk -words
258 .Nm
259 .Fl i | I Ar interface
260 .Op Fl 46abdhnW
261 .Op Fl f Ar address_family
262 .Op Fl M Ar core
263 .Op Fl N Ar system
264 .Op Fl j Ar jail
265 .Ek
266 .Xc
267 Show the state of all network interfaces or a single
268 .Ar interface
269 which have been auto-configured
270 (interfaces statically configured into a system, but not
271 located at boot time are not shown).
272 An asterisk
273 .Pq Dq Li *
274 after an interface name indicates that the interface is
275 .Dq down .
276 .Pp
277 When
278 .Nm
279 is invoked with
280 .Fl i
281 .Pq all interfaces
282 or
283 .Fl I Ar interface ,
284 it provides a table of cumulative
285 statistics regarding packets transferred, errors, and collisions.
286 The network addresses of the interface
287 and the maximum transmission unit
288 .Pq Dq mtu
289 are also displayed.
290 If both
291 .Fl i
292 and
293 .Fl I
294 are specified,
295 .Fl I
296 overrides any instances of
297 .Fl i .
298 .Bl -tag -width indent
299 .It Fl 4
300 Show IPv4 only.
301 See
302 .Sx GENERAL OPTIONS .
303 .It Fl 6
304 Show IPv6 only.
305 See
306 .Sx GENERAL OPTIONS .
307 .It Fl a
308 Multicast addresses currently in use are shown
309 for each Ethernet interface and for each IP interface address.
310 Multicast addresses are shown on separate lines following the interface
311 address with which they are associated.
312 .It Fl b
313 Show the number of bytes in and out.
314 .It Fl d
315 Show the number of dropped packets.
316 .It Fl h
317 Print all counters in human readable form.
318 .It Fl n
319 Do not resolve numeric addresses and port numbers to names.
320 See
321 .Sx GENERAL OPTIONS .
322 .It Fl W
323 Avoid truncating addresses even if this causes some fields to overflow.
324 See
325 .Sx GENERAL OPTIONS .
326 However, in most cases field widths are determined automatically with the
327 .Fl i
328 option, and this option has little effect.
329 .It Fl f Ar protocol_family
330 Filter by
331 .Ar protocol_family .
332 See
333 .Sx GENERAL OPTIONS .
334 .It Fl j Ar jail
335 Run inside a jail.
336 See
337 .Sx GENERAL OPTIONS .
338 .El
339 .It Xo
340 .Bk -words
341 .Nm
342 .Fl w Ar wait
343 .Op Fl I Ar interface
344 .Op Fl 46d
345 .Op Fl M Ar core
346 .Op Fl N Ar system
347 .Op Fl q Ar howmany
348 .Op Fl j Ar jail
349 .Ek
350 .Xc
351 At intervals of
352 .Ar wait
353 seconds, display the information regarding packet traffic on all
354 configured network interfaces or a single
355 .Ar interface .
356 .Pp
357 When
358 .Nm
359 is invoked with the
360 .Fl w
361 option and a
362 .Ar wait
363 interval argument, it displays a running count of statistics related to
364 network interfaces.
365 An obsolescent version of this option used a numeric parameter
366 with no option, and is currently supported for backward compatibility.
367 By default, this display summarizes information for all interfaces.
368 Information for a specific interface may be displayed with the
369 .Fl I Ar interface
370 option.
371 .Bl -tag -width indent
372 .It Fl I Ar interface
373 Only show information regarding
374 .Ar interface
375 .It Fl 4
376 Show IPv4 only.
377 See
378 .Sx GENERAL OPTIONS .
379 .It Fl 6
380 Show IPv6 only.
381 See
382 .Sx GENERAL OPTIONS .
383 .It Fl d
384 Show the number of dropped packets.
385 .It Fl M
386 Use an alternative core.
387 See
388 .Sx GENERAL OPTIONS .
389 .It Fl N
390 Use an alternative kernel image.
391 See
392 .Sx GENERAL OPTIONS .
393 .It Fl q
394 Exit after
395 .Ar howmany
396 outputs.
397 .It Fl j Ar jail
398 Run inside a jail.
399 See
400 .Sx GENERAL OPTIONS .
401 .El
402 .It Xo
403 .Bk -words
404 .Nm
405 .Fl s
406 .Op Fl 46sz
407 .Op Fl f Ar protocol_family | Fl p Ar protocol
408 .Op Fl M Ar core
409 .Op Fl N Ar system
410 .Op Fl j Ar jail
411 .Ek
412 .Xc
413 Display system-wide statistics for each network protocol.
414 .Bl -tag -width indent
415 .It Fl 4
416 Show IPv4 only.
417 See
418 .Sx GENERAL OPTIONS .
419 .It Fl 6
420 Show IPv6 only.
421 See
422 .Sx GENERAL OPTIONS .
423 .It Fl s
424 If
425 .Fl s
426 is repeated, counters with a value of zero are suppressed.
427 .It Fl z
428 Reset statistic counters after displaying them.
429 .It Fl f Ar protocol_family
430 Filter by
431 .Ar protocol_family .
432 See
433 .Sx GENERAL OPTIONS .
434 .It Fl p Ar protocol
435 Filter by
436 .Ar protocol .
437 See
438 .Sx GENERAL OPTIONS .
439 .It Fl M
440 Use an alternative core.
441 See
442 .Sx GENERAL OPTIONS .
443 .It Fl N
444 Use an alternative kernel image
445 See
446 .Sx GENERAL OPTIONS .
447 .It Fl j Ar jail
448 Run inside a jail.
449 See
450 .Sx GENERAL OPTIONS .
451 .El
452 .It Xo
453 .Bk -words
454 .Nm
455 .Fl i | I Ar interface Fl s
456 .Op Fl 46s
457 .Op Fl f Ar protocol_family | Fl p Ar protocol
458 .Op Fl M Ar core
459 .Op Fl N Ar system
460 .Op Fl j Ar jail
461 .Ek
462 .Xc
463 Display per-interface statistics for each network protocol.
464 If both
465 .Fl i
466 and
467 .Fl I
468 are specified,
469 .Fl I
470 overrides any instances of
471 .Fl i .
472 .Bl -tag -width indent
473 .It Fl 4
474 Show IPv4 only
475 See
476 .Sx GENERAL OPTIONS .
477 .It Fl 6
478 Show IPv6 only
479 See
480 .Sx GENERAL OPTIONS .
481 .It Fl s
482 If
483 .Fl s
484 is repeated, counters with a value of zero are suppressed.
485 .It Fl f Ar protocol_family
486 Filter by
487 .Ar protocol_family .
488 See
489 .Sx GENERAL OPTIONS .
490 .It Fl p Ar protocol
491 Filter by
492 .Ar protocol .
493 See
494 .Sx GENERAL OPTIONS .
495 .It Fl M
496 Use an alternative core
497 See
498 .Sx GENERAL OPTIONS .
499 .It Fl N
500 Use an alternative kernel image
501 See
502 .Sx GENERAL OPTIONS .
503 .It Fl j Ar jail
504 Run inside a jail.
505 See
506 .Sx GENERAL OPTIONS .
507 .El
508 .It Xo
509 .Bk -words
510 .Nm
511 .Fl m
512 .Op Fl M Ar core
513 .Op Fl N Ar system
514 .Op Fl j Ar jail
515 .Ek
516 .Xc
517 Show statistics recorded by the memory management routines
518 .Pq Xr mbuf 9 .
519 The network manages a private pool of memory buffers.
520 .Bl -tag -width indent
521 .It Fl M
522 Use an alternative core
523 See
524 .Sx GENERAL OPTIONS .
525 .It Fl N
526 Use an alternative kernel image
527 See
528 .Sx GENERAL OPTIONS .
529 .It Fl j Ar jail
530 Run inside a jail.
531 See
532 .Sx GENERAL OPTIONS .
533 .El
534 .It Xo
535 .Bk -words
536 .Nm
537 .Fl B
538 .Op Fl z
539 .Op Fl I Ar interface
540 .Op Fl j Ar jail
541 .Ek
542 .Xc
543 Show statistics about
544 .Xr bpf 4
545 peers.
546 This includes information like
547 how many packets have been matched, dropped and received by the
548 bpf device, also information about current buffer sizes and device
549 states.
550 .Pp
551 The
552 .Xr bpf 4
553 flags displayed when
554 .Nm
555 is invoked with the
556 .Fl B
557 option represent the underlying parameters of the bpf peer.
558 Each flag is
559 represented as a single lower case letter.
560 The mapping between the letters and flags in order of appearance are:
561 .Bl -column ".Li i"
562 .It Li p Ta Set if listening promiscuously
563 .It Li i Ta Dv BIOCIMMEDIATE No has been set on the device
564 .It Li f Ta Dv BIOCGHDRCMPLT No status: source link addresses are being
565 filled automatically
566 .It Li s Ta Dv BIOCGSEESENT No status: see packets originating locally and
567 remotely on the interface.
568 .It Li a Ta Packet reception generates a signal
569 .It Li l Ta Dv BIOCLOCK No status: descriptor has been locked
570 .El
571 .Pp
572 For more information about these flags, please refer to
573 .Xr bpf 4 .
574 .Bl -tag -width indent
575 .It Fl z
576 Reset statistic counters after displaying them.
577 .It Fl j Ar jail
578 Run inside a jail.
579 See
580 .Sx GENERAL OPTIONS .
581 .El
582 .It Xo
583 .Bk -words
584 .Nm
585 .Fl r
586 .Op Fl 46AnW
587 .Op Fl F Ar fibnum
588 .Op Fl f Ar address_family
589 .Op Fl M Ar core
590 .Op Fl N Ar system
591 .Op Fl j Ar jail
592 .Ek
593 .Xc
594 Display the contents of routing tables.
595 .Pp
596 When
597 .Nm
598 is invoked with the routing table option
599 .Fl r ,
600 it lists the available routes and their status.
601 Each route consists of a destination host or network, and a gateway to use
602 in forwarding packets.
603 The flags field shows a collection of information about the route stored
604 as binary choices.
605 The individual flags are discussed in more detail in the
606 .Xr route 8
607 and
608 .Xr route 4
609 manual pages.
610 The mapping between letters and flags is:
611 .Bl -column ".Li W" ".Dv RTF_WASCLONED"
612 .It Li 1 Ta Dv RTF_PROTO1 Ta "Protocol specific routing flag #1"
613 .It Li 2 Ta Dv RTF_PROTO2 Ta "Protocol specific routing flag #2"
614 .It Li 3 Ta Dv RTF_PROTO3 Ta "Protocol specific routing flag #3"
615 .It Li B Ta Dv RTF_BLACKHOLE Ta "Just discard pkts (during updates)"
616 .It Li b Ta Dv RTF_BROADCAST Ta "The route represents a broadcast address"
617 .It Li D Ta Dv RTF_DYNAMIC Ta "Created dynamically (by redirect)"
618 .It Li G Ta Dv RTF_GATEWAY Ta "Destination requires forwarding by intermediary"
619 .It Li H Ta Dv RTF_HOST Ta "Host entry (net otherwise)"
620 .It Li L Ta Dv RTF_LLINFO Ta "Valid protocol to link address translation"
621 .It Li M Ta Dv RTF_MODIFIED Ta "Modified dynamically (by redirect)"
622 .It Li R Ta Dv RTF_REJECT Ta "Host or net unreachable"
623 .It Li S Ta Dv RTF_STATIC Ta "Manually added"
624 .It Li U Ta Dv RTF_UP Ta "Route usable"
625 .It Li X Ta Dv RTF_XRESOLVE Ta "External daemon translates proto to link address"
626 .El
627 .Pp
628 Direct routes are created for each
629 interface attached to the local host;
630 the gateway field for such entries shows the address of the outgoing interface.
631 The refcnt field gives the
632 current number of active uses of the route.
633 Connection oriented
634 protocols normally hold on to a single route for the duration of
635 a connection while connectionless protocols obtain a route while sending
636 to the same destination.
637 The use field provides a count of the number of packets
638 sent using that route.
639 The interface entry indicates the network interface utilized for the route.
640 .Bl -tag -width indent
641 .It Fl 4
642 Show IPv4 only.
643 See
644 .Sx GENERAL OPTIONS .
645 .It Fl 6
646 Show IPv6 only.
647 See
648 .Sx GENERAL OPTIONS .
649 .It Fl n
650 Do not resolve numeric addresses and port numbers to names.
651 See
652 .Sx GENERAL OPTIONS .
653 .It Fl W
654 Show the path MTU for each route, and print interface names with a
655 wider field size.
656 .It Fl F
657 Display the routing table with the number
658 .Ar fibnum .
659 If the specified
660 .Ar fibnum
661 is -1 or
662 .Fl F
663 is not specified,
664 the default routing table is displayed.
665 .It Fl f
666 Display the routing table for a particular
667 .Ar address_family .
668 .It Fl M
669 Use an alternative core
670 See
671 .Sx GENERAL OPTIONS .
672 .It Fl N
673 Use an alternative kernel image
674 See
675 .Sx GENERAL OPTIONS .
676 .It Fl j Ar jail
677 Run inside a jail.
678 See
679 .Sx GENERAL OPTIONS .
680 .El
681 .It Xo
682 .Bk -words
683 .Nm
684 .Fl rs
685 .Op Fl s
686 .Op Fl M Ar core
687 .Op Fl N Ar system
688 .Op Fl j Ar jail
689 .Ek
690 .Xc
691 Display routing statistics.
692 .Bl -tag -width indent
693 .It Fl s
694 If
695 .Fl s
696 is repeated, counters with a value of zero are suppressed.
697 .It Fl M
698 Use an alternative core
699 See
700 .Sx GENERAL OPTIONS .
701 .It Fl N
702 Use an alternative kernel image
703 See
704 .Sx GENERAL OPTIONS .
705 .It Fl j Ar jail
706 Run inside a jail.
707 See
708 .Sx GENERAL OPTIONS .
709 .El
710 .It Xo
711 .Bk -words
712 .Nm
713 .Fl g
714 .Op Fl 46W
715 .Op Fl f Ar address_family
716 .Op Fl M Ar core
717 .Op Fl N Ar system
718 .Op Fl j Ar jail
719 .Ek
720 .Xc
721 Display the contents of the multicast virtual interface tables,
722 and multicast forwarding caches.
723 Entries in these tables will appear only when the kernel is
724 actively forwarding multicast sessions.
725 This option is applicable only to the
726 .Cm inet
727 and
728 .Cm inet6
729 address families.
730 .Bl -tag -width indent
731 .It Fl 4
732 Show IPv4 only
733 See
734 .Sx GENERAL OPTIONS .
735 .It Fl 6
736 Show IPv6 only
737 See
738 .Sx GENERAL OPTIONS .
739 .It Fl W
740 Avoid truncating addresses even if this causes some fields to overflow.
741 .It Fl f Ar protocol_family
742 Filter by
743 .Ar protocol_family .
744 See
745 .Sx GENERAL OPTIONS .
746 .It Fl M
747 Use an alternative core
748 See
749 .Sx GENERAL OPTIONS .
750 .It Fl N
751 Use an alternative kernel image
752 See
753 .Sx GENERAL OPTIONS .
754 .It Fl j Ar jail
755 Run inside a jail.
756 See
757 .Sx GENERAL OPTIONS .
758 .El
759 .It Xo
760 .Bk -words
761 .Nm
762 .Fl gs
763 .Op Fl 46s
764 .Op Fl f Ar address_family
765 .Op Fl M Ar core
766 .Op Fl N Ar system
767 .Op Fl j Ar jail
768 .Ek
769 .Xc
770 Show multicast routing statistics.
771 .Bl -tag -width indent
772 .It Fl 4
773 Show IPv4 only
774 See
775 .Sx GENERAL OPTIONS .
776 .It Fl 6
777 Show IPv6 only
778 See
779 .Sx GENERAL OPTIONS .
780 .It Fl s
781 If
782 .Fl s
783 is repeated, counters with a value of zero are suppressed.
784 .It Fl f Ar protocol_family
785 Filter by
786 .Ar protocol_family .
787 See
788 .Sx GENERAL OPTIONS .
789 .It Fl M
790 Use an alternative core
791 See
792 .Sx GENERAL OPTIONS .
793 .It Fl N
794 Use an alternative kernel image
795 See
796 .Sx GENERAL OPTIONS .
797 .It Fl j Ar jail
798 Run inside a jail.
799 See
800 .Sx GENERAL OPTIONS .
801 .El
802 .It Xo
803 .Bk -words
804 .Nm
805 .Fl Q
806 .Op Fl j Ar jail
807 .Ek
808 .Xc
809 Show
810 .Xr netisr 9
811 statistics.
812 The flags field shows available ISR handlers:
813 .Bl -column ".Li W" ".Dv NETISR_SNP_FLAGS_DRAINEDCPU"
814 .It Li C Ta Dv NETISR_SNP_FLAGS_M2CPUID Ta "Able to map mbuf to cpu id"
815 .It Li D Ta Dv NETISR_SNP_FLAGS_DRAINEDCPU  Ta "Has queue drain handler"
816 .It Li F Ta Dv NETISR_SNP_FLAGS_M2FLOW Ta "Able to map mbuf to flow id"
817 .It Fl j Ar jail
818 Run inside a jail.
819 See
820 .Sx GENERAL OPTIONS .
821 .El
822 .El
823 .Ss GENERAL OPTIONS
824 Some options have the general meaning:
825 .Bl -tag -width flag
826 .It Fl 4
827 Is shorthand for
828 .Fl f
829 .Ar inet
830 .Pq Show only IPv4
831 .It Fl 6
832 Is shorthand for
833 .Fl f
834 .Ar inet6
835 .Pq Show only IPv6
836 .It Fl f Ar address_family , Fl p Ar protocol
837 Limit display to those records
838 of the specified
839 .Ar address_family
840 or a single
841 .Ar protocol .
842 The following address families and protocols are recognized:
843 .Pp
844 .Bl -tag -width ".Cm netgraph , ng Pq Dv AF_NETGRAPH" -compact
845 .It Em Family
846 .Em Protocols
847 .It Cm inet Pq Dv AF_INET
848 .Cm divert , icmp , igmp , ip , ipsec , pim, sctp , tcp , udp
849 .It Cm inet6 Pq Dv AF_INET6
850 .Cm icmp6 , ip6 , ipsec6 , rip6 , sctp , tcp , udp
851 .It Cm pfkey Pq Dv PF_KEY
852 .Cm pfkey
853 .It Cm netgraph , ng Pq Dv AF_NETGRAPH
854 .Cm ctrl , data
855 .It Cm unix Pq Dv AF_UNIX
856 .It Cm link Pq Dv AF_LINK
857 .El
858 .Pp
859 The program will complain if
860 .Ar protocol
861 is unknown or if there is no statistics routine for it.
862 .It Fl M
863 Extract values associated with the name list from the specified core
864 instead of the default
865 .Pa /dev/kmem .
866 .It Fl N
867 Extract the name list from the specified system instead of the default,
868 which is the kernel image the system has booted from.
869 .It Fl n
870 Show network addresses and ports as numbers.
871 Normally
872 .Nm
873 attempts to resolve addresses and ports,
874 and display them symbolically.
875 .It Fl W
876 Wider output; expand address fields, etc, to avoid truncation.
877 Non-numeric values such as domain names may still be truncated; use the
878 .Fl n
879 option if necessary to avoid ambiguity.
880 .It Fl j Ar jail
881 Perform the actions inside the
882 .Ar jail .
883 This allows network state to be accessed even if the
884 .Cm netstat
885 binary is not available in the
886 .Ar jail .
887 .El
888 .Sh EXAMPLES
889 Show packet traffic information (packets, bytes, errors, packet drops, etc) for
890 interface re0 updated every 2 seconds and exit after 5 outputs:
891 .Bd -literal -offset indent
892 $ netstat -w 2 -q 5 -I re0
893 .Ed
894 .Pp
895 Show statistics for ICMP on any interface:
896 .Bd -literal -offset indent
897 $ netstat -s -p icmp
898 .Ed
899 .Pp
900 Show routing tables:
901 .Bd -literal -offset indent
902 $ netstat -r
903 .Ed
904 .Pp
905 Same as above, but without resolving numeric addresses and port numbers to
906 names:
907 .Bd -literal -offset indent
908 $ netstat -rn
909 .Ed
910 .Sh SEE ALSO
911 .Xr fstat 1 ,
912 .Xr nfsstat 1 ,
913 .Xr procstat 1 ,
914 .Xr ps 1 ,
915 .Xr sockstat 1 ,
916 .Xr libxo 3 ,
917 .Xr xo_parse_args 3 ,
918 .Xr bpf 4 ,
919 .Xr inet 4 ,
920 .Xr route 4 ,
921 .Xr unix 4 ,
922 .Xr hosts 5 ,
923 .Xr networks 5 ,
924 .Xr protocols 5 ,
925 .Xr services 5 ,
926 .Xr iostat 8 ,
927 .Xr route 8 ,
928 .Xr vmstat 8 ,
929 .Xr mbuf 9
930 .Sh HISTORY
931 The
932 .Nm
933 command appeared in
934 .Bx 4.2 .
935 .Pp
936 IPv6 support was added by WIDE/KAME project.
937 .Sh BUGS
938 The notion of errors is ill-defined.