1 .\" Copyright (c) 1983, 1990, 1992, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
33 .Nd show network status and statistics
36 .Bl -tag -width "netstat"
41 .Op Fl f Ar protocol_family | Fl p Ar protocol
42 .It Nm Fl i | I Ar interface
46 .Op Fl f Ar address_family
61 .Op Fl f Ar protocol_family | Fl p Ar protocol
64 .It Nm Fl i | I Ar interface Fl s
68 .Op Fl f Ar protocol_family | Fl p Ar protocol
86 .Op Fl f Ar address_family
97 .Op Fl f Ar address_family
102 .Op Fl f Ar address_family
113 command shows the contents of various network-related
115 The arguments passed determine which of the below output formats the
117 .Bl -tag -width indent
122 .Op Fl f Ar protocol_family | Fl p Ar protocol
126 Display a list of active sockets
127 (protocol control blocks)
128 for each network protocol.
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
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
144 If a symbolic name for an address is unknown, or if
147 option is specified, the address is printed numerically, according
148 to the address family.
149 For more information regarding
157 addresses and ports appear as
159 .Bl -tag -width indent
163 in a selection of different human and machine readable formats.
166 for details on command line arguments.
170 .Sx GENERAL OPTIONS .
174 .Sx GENERAL OPTIONS .
176 Show the address of a protocol control block (PCB)
177 associated with a socket; used for debugging.
179 Show the state of all sockets;
180 normally sockets used by server processes are not shown.
182 Show the used TCP stack for each session.
184 Show the congestion control algorithm and diagnostic information of TCP sockets.
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.
191 Do not resolve numeric addresses and port numbers to names.
193 .Sx GENERAL OPTIONS .
195 Display the log ID for each socket.
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
205 Show network addresses as numbers (as with
207 but show ports symbolically.
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.
213 Avoid truncating addresses even if this causes some fields to overflow.
215 Display socket buffer and TCP timer statistics for each
222 to output all the information recorded about data
223 stored in the socket buffers.
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.
241 .It Fl f Ar protocol_family
243 .Ar protocol_family .
245 .Sx GENERAL OPTIONS .
250 .Sx GENERAL OPTIONS .
254 .Sx GENERAL OPTIONS .
259 .Fl i | I Ar interface
261 .Op Fl f Ar address_family
267 Show the state of all network interfaces or a single
269 which have been auto-configured
270 (interfaces statically configured into a system, but not
271 located at boot time are not shown).
274 after an interface name indicates that the interface is
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
296 overrides any instances of
298 .Bl -tag -width indent
302 .Sx GENERAL OPTIONS .
306 .Sx GENERAL OPTIONS .
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.
313 Show the number of bytes in and out.
315 Show the number of dropped packets.
317 Print all counters in human readable form.
319 Do not resolve numeric addresses and port numbers to names.
321 .Sx GENERAL OPTIONS .
323 Avoid truncating addresses even if this causes some fields to overflow.
325 .Sx GENERAL OPTIONS .
326 However, in most cases field widths are determined automatically with the
328 option, and this option has little effect.
329 .It Fl f Ar protocol_family
331 .Ar protocol_family .
333 .Sx GENERAL OPTIONS .
337 .Sx GENERAL OPTIONS .
343 .Op Fl I Ar interface
353 seconds, display the information regarding packet traffic on all
354 configured network interfaces or a single
363 interval argument, it displays a running count of statistics related to
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
371 .Bl -tag -width indent
372 .It Fl I Ar interface
373 Only show information regarding
378 .Sx GENERAL OPTIONS .
382 .Sx GENERAL OPTIONS .
384 Show the number of dropped packets.
386 Use an alternative core.
388 .Sx GENERAL OPTIONS .
390 Use an alternative kernel image.
392 .Sx GENERAL OPTIONS .
400 .Sx GENERAL OPTIONS .
407 .Op Fl f Ar protocol_family | Fl p Ar protocol
413 Display system-wide statistics for each network protocol.
414 .Bl -tag -width indent
418 .Sx GENERAL OPTIONS .
422 .Sx GENERAL OPTIONS .
426 is repeated, counters with a value of zero are suppressed.
428 Reset statistic counters after displaying them.
429 .It Fl f Ar protocol_family
431 .Ar protocol_family .
433 .Sx GENERAL OPTIONS .
438 .Sx GENERAL OPTIONS .
440 Use an alternative core.
442 .Sx GENERAL OPTIONS .
444 Use an alternative kernel image
446 .Sx GENERAL OPTIONS .
450 .Sx GENERAL OPTIONS .
455 .Fl i | I Ar interface Fl s
457 .Op Fl f Ar protocol_family | Fl p Ar protocol
463 Display per-interface statistics for each network protocol.
470 overrides any instances of
472 .Bl -tag -width indent
476 .Sx GENERAL OPTIONS .
480 .Sx GENERAL OPTIONS .
484 is repeated, counters with a value of zero are suppressed.
485 .It Fl f Ar protocol_family
487 .Ar protocol_family .
489 .Sx GENERAL OPTIONS .
494 .Sx GENERAL OPTIONS .
496 Use an alternative core
498 .Sx GENERAL OPTIONS .
500 Use an alternative kernel image
502 .Sx GENERAL OPTIONS .
506 .Sx GENERAL OPTIONS .
517 Show statistics recorded by the memory management routines
519 The network manages a private pool of memory buffers.
520 .Bl -tag -width indent
522 Use an alternative core
524 .Sx GENERAL OPTIONS .
526 Use an alternative kernel image
528 .Sx GENERAL OPTIONS .
532 .Sx GENERAL OPTIONS .
539 .Op Fl I Ar interface
543 Show statistics about
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
557 option represent the underlying parameters of the bpf peer.
559 represented as a single lower case letter.
560 The mapping between the letters and flags in order of appearance are:
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
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
572 For more information about these flags, please refer to
574 .Bl -tag -width indent
576 Reset statistic counters after displaying them.
580 .Sx GENERAL OPTIONS .
588 .Op Fl f Ar address_family
594 Display the contents of routing tables.
598 is invoked with the routing table option
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
605 The individual flags are discussed in more detail in the
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"
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.
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
644 .Sx GENERAL OPTIONS .
648 .Sx GENERAL OPTIONS .
650 Do not resolve numeric addresses and port numbers to names.
652 .Sx GENERAL OPTIONS .
654 Show the path MTU for each route, and print interface names with a
657 Display the routing table with the number
664 the default routing table is displayed.
666 Display the routing table for a particular
669 Use an alternative core
671 .Sx GENERAL OPTIONS .
673 Use an alternative kernel image
675 .Sx GENERAL OPTIONS .
679 .Sx GENERAL OPTIONS .
691 Display routing statistics.
692 .Bl -tag -width indent
696 is repeated, counters with a value of zero are suppressed.
698 Use an alternative core
700 .Sx GENERAL OPTIONS .
702 Use an alternative kernel image
704 .Sx GENERAL OPTIONS .
708 .Sx GENERAL OPTIONS .
715 .Op Fl f Ar address_family
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
730 .Bl -tag -width indent
734 .Sx GENERAL OPTIONS .
738 .Sx GENERAL OPTIONS .
740 Avoid truncating addresses even if this causes some fields to overflow.
741 .It Fl f Ar protocol_family
743 .Ar protocol_family .
745 .Sx GENERAL OPTIONS .
747 Use an alternative core
749 .Sx GENERAL OPTIONS .
751 Use an alternative kernel image
753 .Sx GENERAL OPTIONS .
757 .Sx GENERAL OPTIONS .
764 .Op Fl f Ar address_family
770 Show multicast routing statistics.
771 .Bl -tag -width indent
775 .Sx GENERAL OPTIONS .
779 .Sx GENERAL OPTIONS .
783 is repeated, counters with a value of zero are suppressed.
784 .It Fl f Ar protocol_family
786 .Ar protocol_family .
788 .Sx GENERAL OPTIONS .
790 Use an alternative core
792 .Sx GENERAL OPTIONS .
794 Use an alternative kernel image
796 .Sx GENERAL OPTIONS .
800 .Sx GENERAL OPTIONS .
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"
820 .Sx GENERAL OPTIONS .
824 Some options have the general meaning:
836 .It Fl f Ar address_family , Fl p Ar protocol
837 Limit display to those records
842 The following address families and protocols are recognized:
844 .Bl -tag -width ".Cm netgraph , ng Pq Dv AF_NETGRAPH" -compact
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
853 .It Cm netgraph , ng Pq Dv AF_NETGRAPH
855 .It Cm unix Pq Dv AF_UNIX
856 .It Cm link Pq Dv AF_LINK
859 The program will complain if
861 is unknown or if there is no statistics routine for it.
863 Extract values associated with the name list from the specified core
864 instead of the default
867 Extract the name list from the specified system instead of the default,
868 which is the kernel image the system has booted from.
870 Show network addresses and ports as numbers.
873 attempts to resolve addresses and ports,
874 and display them symbolically.
876 Wider output; expand address fields, etc, to avoid truncation.
877 Non-numeric values such as domain names may still be truncated; use the
879 option if necessary to avoid ambiguity.
881 Perform the actions inside the
883 This allows network state to be accessed even if the
885 binary is not available in the
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
895 Show statistics for ICMP on any interface:
896 .Bd -literal -offset indent
901 .Bd -literal -offset indent
905 Same as above, but without resolving numeric addresses and port numbers to
907 .Bd -literal -offset indent
917 .Xr xo_parse_args 3 ,
936 IPv6 support was added by WIDE/KAME project.
938 The notion of errors is ill-defined.