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
28 .\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
35 .Nd show network status and statistics
38 .Bl -tag -width "netstat"
43 .Op Fl f Ar protocol_family | Fl p Ar protocol
44 .It Nm Fl i | I Ar interface
48 .Op Fl f Ar address_family
63 .Op Fl f Ar protocol_family | Fl p Ar protocol
66 .It Nm Fl i | I Ar interface Fl s
70 .Op Fl f Ar protocol_family | Fl p Ar protocol
88 .Op Fl f Ar address_family
99 .Op Fl f Ar address_family
104 .Op Fl f Ar address_family
115 command shows the contents of various network-related
117 The arguments passed determine which of the below output formats the
119 .Bl -tag -width indent
124 .Op Fl f Ar protocol_family | Fl p Ar protocol
128 Display a list of active sockets
129 (protocol control blocks)
130 for each network protocol.
132 The default display for active sockets shows the local
133 and remote addresses, send and receive queue sizes (in bytes), protocol,
134 and the internal state of the protocol.
135 Address formats are of the form
139 if a socket's address specifies a network but no specific host address.
140 When known, the host and network addresses are displayed symbolically
141 according to the databases
146 If a symbolic name for an address is unknown, or if
149 option is specified, the address is printed numerically, according
150 to the address family.
151 For more information regarding
159 addresses and ports appear as
161 .Bl -tag -width indent
165 in a selection of different human and machine readable formats.
168 for details on command line arguments.
172 .Sx GENERAL OPTIONS .
176 .Sx GENERAL OPTIONS .
178 Show the address of a protocol control block (PCB)
179 associated with a socket; used for debugging.
181 Show the state of all sockets;
182 normally sockets used by server processes are not shown.
184 Show the used TCP stack for each session.
186 Show the congestion control algorithm and diagnostic information of TCP sockets.
188 Show the size of the various listen queues.
189 The first count shows the number of unaccepted connections,
190 the second count shows the amount of unaccepted incomplete connections,
191 and the third count is the maximum number of queued connections.
193 Do not resolve numeric addresses and port numbers to names.
195 .Sx GENERAL OPTIONS .
197 Display the log ID for each socket.
199 Display the flowid and flowtype for each socket.
200 flowid is a 32 bit hardware specific identifier for each flow.
201 flowtype defines which protocol fields are hashed to produce the id.
202 A complete listing is available in
207 Show network addresses as numbers (as with
209 but show ports symbolically.
211 Display diagnostic information from the TCP control block.
212 Fields include the number of packets requiring retransmission,
213 received out-of-order, and those advertising a zero-sized window.
215 Avoid truncating addresses even if this causes some fields to overflow.
217 Display socket buffer and TCP timer statistics for each
224 to output all the information recorded about data
225 stored in the socket buffers.
227 .Bl -column ".Li R-HIWA"
228 .It Li R-HIWA Ta Receive buffer high water mark, in bytes.
229 .It Li S-HIWA Ta Send buffer high water mark, in bytes.
230 .It Li R-LOWA Ta Receive buffer low water mark, in bytes.
231 .It Li S-LOWA Ta Send buffer low water mark, in bytes.
232 .It Li R-BCNT Ta Receive buffer byte count.
233 .It Li S-BCNT Ta Send buffer byte count.
234 .It Li R-BMAX Ta Maximum bytes that can be used in the receive buffer.
235 .It Li S-BMAX Ta Maximum bytes that can be used in the send buffer.
236 .It Li rexmt Ta Time, in seconds, to fire Retransmit Timer, or 0 if not armed.
237 .It Li persist Ta Time, in seconds, to fire Retransmit Persistence, or 0 if not armed.
238 .It Li keep Ta Time, in seconds, to fire Keep Alive, or 0 if not armed.
239 .It Li 2msl Ta Time, in seconds, to fire 2*msl TIME_WAIT Timer, or 0 if not armed.
240 .It Li delack Ta Time, in seconds, to fire Delayed ACK Timer, or 0 if not armed.
241 .It Li rcvtime Ta Time, in seconds, since last packet received.
243 .It Fl f Ar protocol_family
245 .Ar protocol_family .
247 .Sx GENERAL OPTIONS .
252 .Sx GENERAL OPTIONS .
256 .Sx GENERAL OPTIONS .
261 .Fl i | I Ar interface
263 .Op Fl f Ar address_family
269 Show the state of all network interfaces or a single
271 which have been auto-configured
272 (interfaces statically configured into a system, but not
273 located at boot time are not shown).
276 after an interface name indicates that the interface is
286 it provides a table of cumulative
287 statistics regarding packets transferred, errors, and collisions.
288 The network addresses of the interface
289 and the maximum transmission unit
298 overrides any instances of
300 .Bl -tag -width indent
304 .Sx GENERAL OPTIONS .
308 .Sx GENERAL OPTIONS .
310 Multicast addresses currently in use are shown
311 for each Ethernet interface and for each IP interface address.
312 Multicast addresses are shown on separate lines following the interface
313 address with which they are associated.
315 Show the number of bytes in and out.
317 Show the number of dropped packets.
319 Print all counters in human readable form.
321 Do not resolve numeric addresses and port numbers to names.
323 .Sx GENERAL OPTIONS .
325 Avoid truncating addresses even if this causes some fields to overflow.
327 .Sx GENERAL OPTIONS .
328 However, in most cases field widths are determined automatically with the
330 option, and this option has little effect.
331 .It Fl f Ar protocol_family
333 .Ar protocol_family .
335 .Sx GENERAL OPTIONS .
339 .Sx GENERAL OPTIONS .
345 .Op Fl I Ar interface
355 seconds, display the information regarding packet traffic on all
356 configured network interfaces or a single
365 interval argument, it displays a running count of statistics related to
367 An obsolescent version of this option used a numeric parameter
368 with no option, and is currently supported for backward compatibility.
369 By default, this display summarizes information for all interfaces.
370 Information for a specific interface may be displayed with the
373 .Bl -tag -width indent
374 .It Fl I Ar interface
375 Only show information regarding
380 .Sx GENERAL OPTIONS .
384 .Sx GENERAL OPTIONS .
386 Show the number of dropped packets.
388 Use an alternative core.
390 .Sx GENERAL OPTIONS .
392 Use an alternative kernel image.
394 .Sx GENERAL OPTIONS .
402 .Sx GENERAL OPTIONS .
409 .Op Fl f Ar protocol_family | Fl p Ar protocol
415 Display system-wide statistics for each network protocol.
416 .Bl -tag -width indent
420 .Sx GENERAL OPTIONS .
424 .Sx GENERAL OPTIONS .
428 is repeated, counters with a value of zero are suppressed.
430 Reset statistic counters after displaying them.
431 .It Fl f Ar protocol_family
433 .Ar protocol_family .
435 .Sx GENERAL OPTIONS .
440 .Sx GENERAL OPTIONS .
442 Use an alternative core.
444 .Sx GENERAL OPTIONS .
446 Use an alternative kernel image
448 .Sx GENERAL OPTIONS .
452 .Sx GENERAL OPTIONS .
457 .Fl i | I Ar interface Fl s
459 .Op Fl f Ar protocol_family | Fl p Ar protocol
465 Display per-interface statistics for each network protocol.
472 overrides any instances of
474 .Bl -tag -width indent
478 .Sx GENERAL OPTIONS .
482 .Sx GENERAL OPTIONS .
486 is repeated, counters with a value of zero are suppressed.
487 .It Fl f Ar protocol_family
489 .Ar protocol_family .
491 .Sx GENERAL OPTIONS .
496 .Sx GENERAL OPTIONS .
498 Use an alternative core
500 .Sx GENERAL OPTIONS .
502 Use an alternative kernel image
504 .Sx GENERAL OPTIONS .
508 .Sx GENERAL OPTIONS .
519 Show statistics recorded by the memory management routines
521 The network manages a private pool of memory buffers.
522 .Bl -tag -width indent
524 Use an alternative core
526 .Sx GENERAL OPTIONS .
528 Use an alternative kernel image
530 .Sx GENERAL OPTIONS .
534 .Sx GENERAL OPTIONS .
541 .Op Fl I Ar interface
545 Show statistics about
548 This includes information like
549 how many packets have been matched, dropped and received by the
550 bpf device, also information about current buffer sizes and device
559 option represent the underlying parameters of the bpf peer.
561 represented as a single lower case letter.
562 The mapping between the letters and flags in order of appearance are:
564 .It Li p Ta Set if listening promiscuously
565 .It Li i Ta Dv BIOCIMMEDIATE No has been set on the device
566 .It Li f Ta Dv BIOCGHDRCMPLT No status: source link addresses are being
568 .It Li s Ta Dv BIOCGSEESENT No status: see packets originating locally and
569 remotely on the interface.
570 .It Li a Ta Packet reception generates a signal
571 .It Li l Ta Dv BIOCLOCK No status: descriptor has been locked
574 For more information about these flags, please refer to
576 .Bl -tag -width indent
578 Reset statistic counters after displaying them.
582 .Sx GENERAL OPTIONS .
590 .Op Fl f Ar address_family
596 Display the contents of routing tables.
600 is invoked with the routing table option
602 it lists the available routes and their status.
603 Each route consists of a destination host or network, and a gateway to use
604 in forwarding packets.
605 The flags field shows a collection of information about the route stored
607 The individual flags are discussed in more detail in the
612 The mapping between letters and flags is:
613 .Bl -column ".Li W" ".Dv RTF_WASCLONED"
614 .It Li 1 Ta Dv RTF_PROTO1 Ta "Protocol specific routing flag #1"
615 .It Li 2 Ta Dv RTF_PROTO2 Ta "Protocol specific routing flag #2"
616 .It Li 3 Ta Dv RTF_PROTO3 Ta "Protocol specific routing flag #3"
617 .It Li B Ta Dv RTF_BLACKHOLE Ta "Just discard pkts (during updates)"
618 .It Li b Ta Dv RTF_BROADCAST Ta "The route represents a broadcast address"
619 .It Li D Ta Dv RTF_DYNAMIC Ta "Created dynamically (by redirect)"
620 .It Li G Ta Dv RTF_GATEWAY Ta "Destination requires forwarding by intermediary"
621 .It Li H Ta Dv RTF_HOST Ta "Host entry (net otherwise)"
622 .It Li L Ta Dv RTF_LLINFO Ta "Valid protocol to link address translation"
623 .It Li M Ta Dv RTF_MODIFIED Ta "Modified dynamically (by redirect)"
624 .It Li R Ta Dv RTF_REJECT Ta "Host or net unreachable"
625 .It Li S Ta Dv RTF_STATIC Ta "Manually added"
626 .It Li U Ta Dv RTF_UP Ta "Route usable"
627 .It Li X Ta Dv RTF_XRESOLVE Ta "External daemon translates proto to link address"
630 Direct routes are created for each
631 interface attached to the local host;
632 the gateway field for such entries shows the address of the outgoing interface.
633 The refcnt field gives the
634 current number of active uses of the route.
636 protocols normally hold on to a single route for the duration of
637 a connection while connectionless protocols obtain a route while sending
638 to the same destination.
639 The use field provides a count of the number of packets
640 sent using that route.
641 The interface entry indicates the network interface utilized for the route.
642 .Bl -tag -width indent
646 .Sx GENERAL OPTIONS .
650 .Sx GENERAL OPTIONS .
652 Do not resolve numeric addresses and port numbers to names.
654 .Sx GENERAL OPTIONS .
656 Show the path MTU for each route, and print interface names with a
659 Display the routing table with the number
666 the default routing table is displayed.
668 Display the routing table for a particular
671 Use an alternative core
673 .Sx GENERAL OPTIONS .
675 Use an alternative kernel image
677 .Sx GENERAL OPTIONS .
681 .Sx GENERAL OPTIONS .
693 Display routing statistics.
694 .Bl -tag -width indent
698 is repeated, counters with a value of zero are suppressed.
700 Use an alternative core
702 .Sx GENERAL OPTIONS .
704 Use an alternative kernel image
706 .Sx GENERAL OPTIONS .
710 .Sx GENERAL OPTIONS .
717 .Op Fl f Ar address_family
723 Display the contents of the multicast virtual interface tables,
724 and multicast forwarding caches.
725 Entries in these tables will appear only when the kernel is
726 actively forwarding multicast sessions.
727 This option is applicable only to the
732 .Bl -tag -width indent
736 .Sx GENERAL OPTIONS .
740 .Sx GENERAL OPTIONS .
742 Avoid truncating addresses even if this causes some fields to overflow.
743 .It Fl f Ar protocol_family
745 .Ar protocol_family .
747 .Sx GENERAL OPTIONS .
749 Use an alternative core
751 .Sx GENERAL OPTIONS .
753 Use an alternative kernel image
755 .Sx GENERAL OPTIONS .
759 .Sx GENERAL OPTIONS .
766 .Op Fl f Ar address_family
772 Show multicast routing statistics.
773 .Bl -tag -width indent
777 .Sx GENERAL OPTIONS .
781 .Sx GENERAL OPTIONS .
785 is repeated, counters with a value of zero are suppressed.
786 .It Fl f Ar protocol_family
788 .Ar protocol_family .
790 .Sx GENERAL OPTIONS .
792 Use an alternative core
794 .Sx GENERAL OPTIONS .
796 Use an alternative kernel image
798 .Sx GENERAL OPTIONS .
802 .Sx GENERAL OPTIONS .
814 The flags field shows available ISR handlers:
815 .Bl -column ".Li W" ".Dv NETISR_SNP_FLAGS_DRAINEDCPU"
816 .It Li C Ta Dv NETISR_SNP_FLAGS_M2CPUID Ta "Able to map mbuf to cpu id"
817 .It Li D Ta Dv NETISR_SNP_FLAGS_DRAINEDCPU Ta "Has queue drain handler"
818 .It Li F Ta Dv NETISR_SNP_FLAGS_M2FLOW Ta "Able to map mbuf to flow id"
822 .Sx GENERAL OPTIONS .
826 Some options have the general meaning:
838 .It Fl f Ar address_family , Fl p Ar protocol
839 Limit display to those records
844 The following address families and protocols are recognized:
846 .Bl -tag -width ".Cm netgraph , ng Pq Dv AF_NETGRAPH" -compact
849 .It Cm inet Pq Dv AF_INET
850 .Cm divert , icmp , igmp , ip , ipsec , pim, sctp , tcp , udp
851 .It Cm inet6 Pq Dv AF_INET6
852 .Cm icmp6 , ip6 , ipsec6 , rip6 , sctp , tcp , udp
853 .It Cm pfkey Pq Dv PF_KEY
855 .It Cm netgraph , ng Pq Dv AF_NETGRAPH
857 .It Cm unix Pq Dv AF_UNIX
858 .It Cm link Pq Dv AF_LINK
861 The program will complain if
863 is unknown or if there is no statistics routine for it.
865 Extract values associated with the name list from the specified core
866 instead of the default
869 Extract the name list from the specified system instead of the default,
870 which is the kernel image the system has booted from.
872 Show network addresses and ports as numbers.
875 attempts to resolve addresses and ports,
876 and display them symbolically.
878 Wider output; expand address fields, etc, to avoid truncation.
879 Non-numeric values such as domain names may still be truncated; use the
881 option if necessary to avoid ambiguity.
883 Perform the actions inside the
885 This allows network state to be accessed even if the
887 binary is not available in the
891 Show packet traffic information (packets, bytes, errors, packet drops, etc) for
892 interface re0 updated every 2 seconds and exit after 5 outputs:
893 .Bd -literal -offset indent
894 $ netstat -w 2 -q 5 -I re0
897 Show statistics for ICMP on any interface:
898 .Bd -literal -offset indent
903 .Bd -literal -offset indent
907 Same as above, but without resolving numeric addresses and port numbers to
909 .Bd -literal -offset indent
919 .Xr xo_parse_args 3 ,
938 IPv6 support was added by WIDE/KAME project.
940 The notion of errors is ill-defined.