[BACK]Return to netstat.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / netstat

Annotation of src/usr.bin/netstat/netstat.1, Revision 1.96

1.96    ! jmc         1: .\"    $OpenBSD: netstat.1,v 1.95 2022/09/08 13:18:47 kn Exp $
1.1       deraadt     2: .\"    $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $
                      3: .\"
                      4: .\" Copyright (c) 1983, 1990, 1992, 1993
                      5: .\"    The Regents of the University of California.  All rights reserved.
                      6: .\"
                      7: .\" Redistribution and use in source and binary forms, with or without
                      8: .\" modification, are permitted provided that the following conditions
                      9: .\" are met:
                     10: .\" 1. Redistributions of source code must retain the above copyright
                     11: .\"    notice, this list of conditions and the following disclaimer.
                     12: .\" 2. Redistributions in binary form must reproduce the above copyright
                     13: .\"    notice, this list of conditions and the following disclaimer in the
                     14: .\"    documentation and/or other materials provided with the distribution.
1.29      millert    15: .\" 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    16: .\"    may be used to endorse or promote products derived from this software
                     17: .\"    without specific prior written permission.
                     18: .\"
                     19: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     20: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     23: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29: .\" SUCH DAMAGE.
                     30: .\"
                     31: .\"    from: @(#)netstat.1     8.8 (Berkeley) 4/18/94
                     32: .\"
1.96    ! jmc        33: .Dd $Mdocdate: September 8 2022 $
1.1       deraadt    34: .Dt NETSTAT 1
1.16      aaron      35: .Os
1.1       deraadt    36: .Sh NAME
                     37: .Nm netstat
                     38: .Nd show network status
                     39: .Sh SYNOPSIS
1.85      jmc        40: .Nm
1.81      benno      41: .Op Fl AaBln
1.1       deraadt    42: .Op Fl M Ar core
                     43: .Op Fl N Ar system
1.59      blambert   44: .Op Fl p Ar protocol
1.83      kn         45: .Op Fl T Ar rtable
1.85      jmc        46: .Nm
1.88      jmc        47: .Fl W Ar interface
                     48: .Nm
                     49: .Fl m
                     50: .Nm
                     51: .Fl I Ar interface | Fl i
1.95      kn         52: .Op Fl bdehnq
1.88      jmc        53: .Nm
                     54: .Fl w Ar wait
1.95      kn         55: .Op Fl bdehnq
1.57      tedu       56: .Op Fl c Ar count
1.1       deraadt    57: .Op Fl I Ar interface
1.88      jmc        58: .Nm
                     59: .Fl s
                     60: .Op Fl gru
                     61: .Op Fl f Ar address_family
                     62: .Op Fl p Ar protocol
                     63: .Nm
                     64: .Fl g
                     65: .Op Fl lnu
                     66: .Op Fl f Ar address_family
                     67: .Nm
                     68: .Fl R
                     69: .Nm
                     70: .Fl r
                     71: .Op Fl AFu
                     72: .Op Fl f Ar address_family
1.1       deraadt    73: .Op Fl M Ar core
                     74: .Op Fl N Ar system
1.88      jmc        75: .Op Fl p Ar protocol
                     76: .Op Fl T Ar rtable
1.85      jmc        77: .Nm
1.88      jmc        78: .Fl P Ar pcbaddr
1.61      bluhm      79: .Op Fl v
1.45      jaredy     80: .Op Fl M Ar core
                     81: .Op Fl N Ar system
1.1       deraadt    82: .Sh DESCRIPTION
                     83: The
1.21      aaron      84: .Nm
1.88      jmc        85: command shows various aspects of network status.
                     86: The default display shows information about
                     87: all active network connections and sockets.
1.21      aaron      88: .Pp
1.1       deraadt    89: The first form of the command displays a list of active sockets for
                     90: each protocol.
1.88      jmc        91: The second form displays per-interface statistics for
                     92: the specified wireless (802.11) device.
                     93: The third form displays statistics related to memory use.
                     94: The fourth form displays per-interface statistics.
                     95: The fifth form continuously displays the information regarding packet
1.1       deraadt    96: traffic on the configured network interfaces.
1.88      jmc        97: The sixth form displays per-protocol statistics.
                     98: The seventh form shows information related to multicast routing.
                     99: The eighth form displays information about routing domains.
                    100: The ninth form displays information about routing tables.
                    101: The final form displays internals of the protocol control block (PCB)
1.61      bluhm     102: and the socket structure.
1.88      jmc       103: The forms are shown in order of precedence:
                    104: for example, if
                    105: .Fl rg
                    106: is specified,
                    107: then
                    108: .Fl r
                    109: is ignored in favour of
                    110: .Fl g .
1.1       deraadt   111: .Pp
1.12      aaron     112: The options are as follows:
1.22      aaron     113: .Bl -tag -width Ds
1.1       deraadt   114: .It Fl A
1.76      jmc       115: Show the address of any protocol control blocks associated with sockets;
                    116: useful for debugging e.g. with the
1.45      jaredy    117: .Fl P
                    118: flag.
1.75      claudio   119: When used with the
1.76      jmc       120: .Fl r
1.93      naddy     121: flag, it shows the internal addresses of the routing table.
1.76      jmc       122: Only the super-user can see these addresses;
                    123: unprivileged users will see them as 0x0.
1.1       deraadt   124: .It Fl a
                    125: With the default display,
                    126: show the state of all sockets; normally sockets used by
                    127: server processes are not shown.
1.63      jsing     128: .It Fl B
                    129: With the default display,
                    130: show buffer sizes for TCP sockets.
                    131: This includes the send window size, receive window size and congestion
                    132: window size.
1.24      camield   133: .It Fl b
1.34      jmc       134: With the interface display (options
                    135: .Fl I
                    136: or
1.24      camield   137: .Fl i ) ,
                    138: show bytes in and out, instead of packet statistics.
1.57      tedu      139: .It Fl c Ar count
                    140: Display
                    141: .Ar count
                    142: updates, then exit.
                    143: This option has no effect unless
                    144: .Fl w
                    145: is specified as well.
1.1       deraadt   146: .It Fl d
1.34      jmc       147: With either the interface display (options
                    148: .Fl I
                    149: or
                    150: .Fl i )
                    151: or an interval (option
                    152: .Fl w ) ,
1.84      dlg       153: show only the number of dropped packets.
                    154: .It Fl e
                    155: With either the interface display (options
                    156: .Fl I
                    157: or
                    158: .Fl i )
                    159: or an interval (option
                    160: .Fl w ) ,
                    161: show only the number of errors on the interface.
1.48      pyr       162: .It Fl F
                    163: When showing routes, only show routes whose gateway are in the
                    164: same address family as the destination.
1.16      aaron     165: .It Fl f Ar address_family
1.1       deraadt   166: Limit statistics or address control block reports to those
                    167: of the specified
1.12      aaron     168: .Ar address_family .
1.21      aaron     169: .Pp
                    170: The following address families are recognized:
1.92      schwarze  171: .Bl -column "Address Family" AF_INET6 Description -offset indent
                    172: .It Sy Address Family Ta Sy Constant Ta Sy Description
                    173: .It Cm inet  Ta Dv AF_INET  Ta IP Version 4
                    174: .It Cm inet6 Ta Dv AF_INET6 Ta IP Version 6
                    175: .It Cm local Ta Dv AF_UNIX  Ta Alias for Cm unix
                    176: .It Cm mpls  Ta Dv AF_MPLS  Ta MPLS
                    177: .It Cm unix  Ta Dv AF_UNIX  Ta Local to Host (i.e., pipes)
1.21      aaron     178: .El
1.68      tedu      179: .It Fl h
                    180: Use unit suffixes to reduce the number of digits shown with the
                    181: .Fl b
                    182: and
                    183: .Fl w
                    184: options.
1.1       deraadt   185: .It Fl g
                    186: Show information related to multicast (group address) routing.
1.34      jmc       187: By default, show the IP multicast virtual-interface and routing tables.
1.1       deraadt   188: If the
                    189: .Fl s
                    190: option is also present, show multicast routing statistics.
1.16      aaron     191: .It Fl I Ar interface
1.21      aaron     192: Show information about the specified
                    193: .Ar interface ;
1.1       deraadt   194: used with a
                    195: .Ar wait
                    196: interval as described below.
                    197: .It Fl i
                    198: Show the state of interfaces which have been auto-configured
1.21      aaron     199: (interfaces statically configured into a system but not
                    200: located at boot-time are not shown).
1.31      jmc       201: .It Fl l
1.81      benno     202: With the default display,
                    203: show only listening sockets.
1.31      jmc       204: With the
                    205: .Fl g
                    206: option, display wider fields for the IPv6 multicast routing table
                    207: .Qq Origin
                    208: and
                    209: .Qq Group
                    210: columns.
1.17      deraadt   211: .It Fl M Ar core
1.1       deraadt   212: Extract values associated with the name list from the specified core
1.27      miod      213: instead of the running kernel.
1.1       deraadt   214: .It Fl m
                    215: Show statistics recorded by the memory management routines
                    216: (the network manages a private pool of memory buffers).
1.17      deraadt   217: .It Fl N Ar system
1.27      miod      218: Extract the name list from the specified system instead of the running kernel.
1.1       deraadt   219: .It Fl n
                    220: Show network addresses as numbers (normally
1.21      aaron     221: .Nm
1.1       deraadt   222: interprets addresses and attempts to display them
                    223: symbolically).
                    224: This option may be used with any of the display formats.
1.45      jaredy    225: .It Fl P Ar pcbaddr
1.75      claudio   226: Display the contents of the protocol control block (PCB)
1.61      bluhm     227: located at the kernel virtual address
1.45      jaredy    228: .Ar pcbaddr .
                    229: PCB addresses can be obtained using the
                    230: .Fl A
                    231: flag.
1.61      bluhm     232: When used with the
                    233: .Fl v
                    234: option, also print socket, domain and protocol specific structures.
1.76      jmc       235: Only the super-user can use the
                    236: .Fl P
                    237: option.
1.80      jca       238: .Pp
                    239: The
                    240: .Fl P
                    241: option requires the ability to open
                    242: .Pa /dev/kmem
                    243: which may be restricted based upon the value of the
                    244: .Ar kern.allowkmem
                    245: .Xr sysctl 8 .
1.16      aaron     246: .It Fl p Ar protocol
1.35      markus    247: Restrict the output to
1.12      aaron     248: .Ar protocol ,
1.21      aaron     249: which is either a well-known name for a protocol or an alias for it.
                    250: Some protocol names and aliases are listed in the file
1.1       deraadt   251: .Pa /etc/protocols .
                    252: The program will complain if
                    253: .Ar protocol
1.35      markus    254: is unknown.
                    255: If the
                    256: .Fl s
                    257: option is specified, the per-protocol statistics are displayed.
                    258: Otherwise the states of the matching sockets are shown.
1.26      brian     259: .It Fl q
                    260: Only show interfaces that have seen packets (or bytes if
                    261: .Fl b
1.34      jmc       262: is specified).
1.87      remi      263: .It Fl R
                    264: List all rdomains with associated interfaces and routing tables.
1.1       deraadt   265: .It Fl r
                    266: Show the routing tables.
1.86      jmc       267: The output is explained in more detail below.
1.21      aaron     268: If the
1.1       deraadt   269: .Fl s
1.21      aaron     270: option is also specified, show routing statistics instead.
1.60      sobrado   271: When used with the
                    272: .Fl v
                    273: option, also print routing labels.
1.26      brian     274: .It Fl s
                    275: Show per-protocol statistics.
                    276: If this option is repeated, counters with a value of zero are suppressed.
1.83      kn        277: .It Fl T Ar rtable
1.67      mikeb     278: Select an alternate routing table to query.
                    279: The default is to use the current routing table.
1.31      jmc       280: .It Fl u
                    281: Limit statistics or address control block reports to the
                    282: .Dv AF_UNIX
                    283: address family.
1.10      peter     284: .It Fl v
1.60      sobrado   285: Show extra (verbose) detail for the routing tables
                    286: .Pq Fl r ,
                    287: or avoid truncation of long addresses.
1.61      bluhm     288: When used with the
                    289: .Fl P
                    290: option, also print socket, domain and protocol specific structures.
1.42      reyk      291: .It Fl W Ar interface
                    292: (IEEE 802.11 devices only)
                    293: Show per-interface IEEE 802.11 wireless statistics.
1.1       deraadt   294: .It Fl w Ar wait
                    295: Show network interface statistics at intervals of
                    296: .Ar wait
                    297: seconds.
                    298: .El
1.21      aaron     299: .Pp
                    300: Address formats are of the form
                    301: .Dq host.port
                    302: or
                    303: .Dq network.port
1.1       deraadt   304: if a socket's address specifies a network but no specific host address.
1.72      schwarze  305: When known, the host addresses are displayed symbolically
                    306: according to the
                    307: .Xr hosts 5
                    308: database.
1.21      aaron     309: If a symbolic name for an address is unknown, or if the
1.1       deraadt   310: .Fl n
                    311: option is specified, the address is printed numerically, according
                    312: to the address family.
1.21      aaron     313: .Pp
                    314: For more information regarding the Internet
                    315: .Dq dot format ,
1.1       deraadt   316: refer to
1.71      jmc       317: .Xr inet_ntop 3 .
1.34      jmc       318: Unspecified or
1.21      aaron     319: .Dq wildcard
                    320: addresses and ports appear as a single
1.34      jmc       321: .Sq * .
1.6       deraadt   322: If a local port number is registered as being in use for RPC by
1.12      aaron     323: .Xr portmap 8 ,
1.11      aaron     324: its RPC service name or RPC service number will be printed in
1.21      aaron     325: .Dq []
                    326: immediately after the port number.
1.1       deraadt   327: .Pp
                    328: The interface display provides a table of cumulative
                    329: statistics regarding packets transferred, errors, and collisions.
                    330: The network addresses of the interface
1.21      aaron     331: and the maximum transmission unit (MTU) are also displayed.
1.1       deraadt   332: .Pp
1.21      aaron     333: The routing table display indicates the available routes and their status.
                    334: Each route consists of a destination host or network and
                    335: a gateway to use in forwarding packets.
                    336: If the destination is a
                    337: network in numeric format, the netmask (in /24 style format) is appended.
                    338: The flags field shows a collection of information about
                    339: the route stored as binary choices.
                    340: The individual flags are discussed in more detail in the
1.1       deraadt   341: .Xr route 8
                    342: and
                    343: .Xr route 4
                    344: manual pages.
                    345: .Pp
1.21      aaron     346: Direct routes are created for each interface attached to the local host;
1.1       deraadt   347: the gateway field for such entries shows the address of the outgoing interface.
1.21      aaron     348: The refcnt field gives the current number of active uses of the route.
                    349: Connection oriented protocols normally hold on to a single route for the
                    350: duration of a connection while connectionless protocols obtain a route while
                    351: sending to the same destination.
                    352: The use field provides a count of the number of packets sent using that route.
                    353: The MTU entry shows the MTU associated with that route.
                    354: This MTU value is used as the basis for the TCP maximum segment size (MSS).
1.34      jmc       355: The
                    356: .Sq L
                    357: flag appended to the MTU value indicates that the value is
                    358: locked, and that path MTU discovery is turned off for that route.
1.21      aaron     359: A
1.1       deraadt   360: .Sq -
1.12      aaron     361: indicates that the MTU for this route has not been set, and a default
1.21      aaron     362: TCP maximum segment size will be used.
                    363: The interface entry indicates the network interface utilized for the route.
1.1       deraadt   364: .Pp
                    365: When
1.21      aaron     366: .Nm
1.1       deraadt   367: is invoked with the
                    368: .Fl w
                    369: option and a
                    370: .Ar wait
                    371: interval argument, it displays a running count of statistics related to
                    372: network interfaces.
                    373: An obsolescent version of this option used a numeric parameter
                    374: with no option, and is currently supported for backward compatibility.
                    375: This display consists of a column for the primary interface (the first
                    376: interface found during autoconfiguration) and a column summarizing
                    377: information for all interfaces.
                    378: The primary interface may be replaced with another interface with the
                    379: .Fl I
                    380: option.
                    381: The first line of each screen of information contains a summary since the
1.21      aaron     382: system was last rebooted.
                    383: Subsequent lines of output show values accumulated over the preceding interval.
1.1       deraadt   384: .Sh SEE ALSO
1.47      jmc       385: .Xr fstat 1 ,
1.1       deraadt   386: .Xr nfsstat 1 ,
                    387: .Xr ps 1 ,
1.47      jmc       388: .Xr systat 1 ,
1.53      jmc       389: .Xr tcpbench 1 ,
1.47      jmc       390: .Xr top 1 ,
1.71      jmc       391: .Xr inet_ntop 3 ,
1.21      aaron     392: .Xr netintro 4 ,
1.34      jmc       393: .Xr route 4 ,
1.1       deraadt   394: .Xr hosts 5 ,
                    395: .Xr protocols 5 ,
                    396: .Xr services 5 ,
1.15      alex      397: .Xr iostat 8 ,
1.34      jmc       398: .Xr portmap 8 ,
1.47      jmc       399: .Xr pstat 8 ,
1.34      jmc       400: .Xr route 8 ,
1.40      jmc       401: .Xr tcpdrop 8 ,
1.1       deraadt   402: .Xr trpt 8 ,
                    403: .Xr vmstat 8
                    404: .Sh HISTORY
                    405: The
1.21      aaron     406: .Nm
1.1       deraadt   407: command appeared in
                    408: .Bx 4.2 .
1.62      schwarze  409: IPv6 support was added by the WIDE/KAME project.
1.1       deraadt   410: .Sh BUGS
                    411: The notion of errors is ill-defined.