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