[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.87

1.87    ! remi        1: .\"    $OpenBSD: netstat.1,v 1.86 2019/04/17 20:34:21 jmc 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.86      jmc        33: .Dd $Mdocdate: April 17 2019 $
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 f Ar address_family
1.59      blambert   43: .Op Fl p Ar protocol
1.1       deraadt    44: .Op Fl M Ar core
                     45: .Op Fl N Ar system
1.85      jmc        46: .Nm
1.84      dlg        47: .Op Fl bdeFgilmnqrstu
1.1       deraadt    48: .Op Fl f Ar address_family
1.59      blambert   49: .Op Fl p Ar protocol
1.1       deraadt    50: .Op Fl M Ar core
                     51: .Op Fl N Ar system
1.83      kn         52: .Op Fl T Ar rtable
1.85      jmc        53: .Nm
1.84      dlg        54: .Op Fl bdehn
1.57      tedu       55: .Op Fl c Ar count
1.1       deraadt    56: .Op Fl I Ar interface
                     57: .Op Fl M Ar core
                     58: .Op Fl N Ar system
                     59: .Op Fl w Ar wait
1.85      jmc        60: .Nm
1.61      bluhm      61: .Op Fl v
1.45      jaredy     62: .Op Fl M Ar core
                     63: .Op Fl N Ar system
                     64: .Fl P Ar pcbaddr
1.85      jmc        65: .Nm
1.35      markus     66: .Op Fl s
1.1       deraadt    67: .Op Fl M Ar core
                     68: .Op Fl N Ar system
1.31      jmc        69: .Op Fl p Ar protocol
1.85      jmc        70: .Nm
1.34      jmc        71: .Op Fl a
1.19      itojun     72: .Op Fl f Ar address_family
1.59      blambert   73: .Op Fl p Ar protocol
1.34      jmc        74: .Op Fl i | I Ar interface
1.85      jmc        75: .Nm
1.42      reyk       76: .Op Fl W Ar interface
1.87    ! remi       77: .Nm
        !            78: .Op Fl R
1.1       deraadt    79: .Sh DESCRIPTION
                     80: The
1.21      aaron      81: .Nm
1.1       deraadt    82: command symbolically displays the contents of various network-related
                     83: data structures.
                     84: There are a number of output formats,
                     85: depending on the options for the information presented.
1.21      aaron      86: .Pp
1.1       deraadt    87: The first form of the command displays a list of active sockets for
                     88: each protocol.
                     89: The second form presents the contents of one of the other network
                     90: data structures according to the option selected.
                     91: Using the third form, with a
                     92: .Ar wait
                     93: interval specified,
1.21      aaron      94: .Nm
1.1       deraadt    95: will continuously display the information regarding packet
                     96: traffic on the configured network interfaces.
1.61      bluhm      97: The fourth form displays internals of the protocol control block (PCB)
                     98: and the socket structure.
1.46      jmc        99: The fifth form displays statistics about the named protocol.
                    100: The sixth form displays per interface statistics for
1.30      jmc       101: the specified address family.
1.43      jmc       102: The final form displays per interface statistics for
                    103: the specified wireless (802.11) device.
1.1       deraadt   104: .Pp
1.12      aaron     105: The options are as follows:
1.22      aaron     106: .Bl -tag -width Ds
1.1       deraadt   107: .It Fl A
1.76      jmc       108: Show the address of any protocol control blocks associated with sockets;
                    109: useful for debugging e.g. with the
1.45      jaredy    110: .Fl P
                    111: flag.
1.75      claudio   112: When used with the
1.76      jmc       113: .Fl r
                    114: flag it shows the internal addresses of the routing table.
                    115: Only the super-user can see these addresses;
                    116: unprivileged users will see them as 0x0.
1.1       deraadt   117: .It Fl a
                    118: With the default display,
                    119: show the state of all sockets; normally sockets used by
                    120: server processes are not shown.
1.63      jsing     121: .It Fl B
                    122: With the default display,
                    123: show buffer sizes for TCP sockets.
                    124: This includes the send window size, receive window size and congestion
                    125: window size.
1.24      camield   126: .It Fl b
1.34      jmc       127: With the interface display (options
                    128: .Fl I
                    129: or
1.24      camield   130: .Fl i ) ,
                    131: show bytes in and out, instead of packet statistics.
1.57      tedu      132: .It Fl c Ar count
                    133: Display
                    134: .Ar count
                    135: updates, then exit.
                    136: This option has no effect unless
                    137: .Fl w
                    138: is specified as well.
1.1       deraadt   139: .It Fl d
1.34      jmc       140: With either the interface display (options
                    141: .Fl I
                    142: or
                    143: .Fl i )
                    144: or an interval (option
                    145: .Fl w ) ,
1.84      dlg       146: show only the number of dropped packets.
                    147: .It Fl e
                    148: With either the interface display (options
                    149: .Fl I
                    150: or
                    151: .Fl i )
                    152: or an interval (option
                    153: .Fl w ) ,
                    154: show only the number of errors on the interface.
1.48      pyr       155: .It Fl F
                    156: When showing routes, only show routes whose gateway are in the
                    157: same address family as the destination.
1.16      aaron     158: .It Fl f Ar address_family
1.1       deraadt   159: Limit statistics or address control block reports to those
                    160: of the specified
1.12      aaron     161: .Ar address_family .
1.21      aaron     162: .Pp
                    163: The following address families are recognized:
1.65      jmc       164: .Bl -column "Address Family" "AF_APPLETA" "Description" -offset indent
1.21      aaron     165: .It Sy "Address Family" Ta Sy "Constant" Ta Sy "Description"
1.32      jmc       166: .It "inet" Ta Dv "AF_INET" Ta "IP Version 4"
                    167: .It "inet6" Ta Dv "AF_INET6" Ta "IP Version 6"
1.82      guenther  168: .It "local" Ta Dv "AF_UNIX" Ta "Alias for unix"
1.55      mk        169: .It "mpls" Ta Dv "AF_MPLS" Ta "MPLS"
1.32      jmc       170: .It "unix" Ta Dv "AF_UNIX" Ta "Local to Host (i.e., pipes)"
1.21      aaron     171: .El
1.68      tedu      172: .It Fl h
                    173: Use unit suffixes to reduce the number of digits shown with the
                    174: .Fl b
                    175: and
                    176: .Fl w
                    177: options.
1.1       deraadt   178: .It Fl g
                    179: Show information related to multicast (group address) routing.
1.34      jmc       180: By default, show the IP multicast virtual-interface and routing tables.
1.1       deraadt   181: If the
                    182: .Fl s
                    183: option is also present, show multicast routing statistics.
1.16      aaron     184: .It Fl I Ar interface
1.21      aaron     185: Show information about the specified
                    186: .Ar interface ;
1.1       deraadt   187: used with a
                    188: .Ar wait
                    189: interval as described below.
1.21      aaron     190: .Pp
1.19      itojun    191: If the
                    192: .Fl f Ar address_family
                    193: option (with the
                    194: .Fl s
1.30      jmc       195: option) is present, show per-interface
                    196: statistics on the given interface for the specified
                    197: .Ar address_family .
1.1       deraadt   198: .It Fl i
                    199: Show the state of interfaces which have been auto-configured
1.21      aaron     200: (interfaces statically configured into a system but not
                    201: located at boot-time are not shown).
                    202: .Pp
1.19      itojun    203: If the
                    204: .Fl f Ar address_family
                    205: option (with the
                    206: .Fl s
1.30      jmc       207: option) is present, show per-interface statistics on all interfaces
1.21      aaron     208: for the specified
1.30      jmc       209: .Ar address_family .
1.31      jmc       210: .It Fl l
1.81      benno     211: With the default display,
                    212: show only listening sockets.
1.31      jmc       213: With the
                    214: .Fl g
                    215: option, display wider fields for the IPv6 multicast routing table
                    216: .Qq Origin
                    217: and
                    218: .Qq Group
                    219: columns.
1.17      deraadt   220: .It Fl M Ar core
1.1       deraadt   221: Extract values associated with the name list from the specified core
1.27      miod      222: instead of the running kernel.
1.1       deraadt   223: .It Fl m
                    224: Show statistics recorded by the memory management routines
                    225: (the network manages a private pool of memory buffers).
1.17      deraadt   226: .It Fl N Ar system
1.27      miod      227: Extract the name list from the specified system instead of the running kernel.
1.1       deraadt   228: .It Fl n
                    229: Show network addresses as numbers (normally
1.21      aaron     230: .Nm
1.1       deraadt   231: interprets addresses and attempts to display them
                    232: symbolically).
                    233: This option may be used with any of the display formats.
1.45      jaredy    234: .It Fl P Ar pcbaddr
1.75      claudio   235: Display the contents of the protocol control block (PCB)
1.61      bluhm     236: located at the kernel virtual address
1.45      jaredy    237: .Ar pcbaddr .
                    238: PCB addresses can be obtained using the
                    239: .Fl A
                    240: flag.
1.61      bluhm     241: When used with the
                    242: .Fl v
                    243: option, also print socket, domain and protocol specific structures.
1.76      jmc       244: Only the super-user can use the
                    245: .Fl P
                    246: option.
1.80      jca       247: .Pp
                    248: The
                    249: .Fl P
                    250: option requires the ability to open
                    251: .Pa /dev/kmem
                    252: which may be restricted based upon the value of the
                    253: .Ar kern.allowkmem
                    254: .Xr sysctl 8 .
1.16      aaron     255: .It Fl p Ar protocol
1.35      markus    256: Restrict the output to
1.12      aaron     257: .Ar protocol ,
1.21      aaron     258: which is either a well-known name for a protocol or an alias for it.
                    259: Some protocol names and aliases are listed in the file
1.1       deraadt   260: .Pa /etc/protocols .
                    261: The program will complain if
                    262: .Ar protocol
1.35      markus    263: is unknown.
                    264: If the
                    265: .Fl s
                    266: option is specified, the per-protocol statistics are displayed.
                    267: Otherwise the states of the matching sockets are shown.
1.26      brian     268: .It Fl q
                    269: Only show interfaces that have seen packets (or bytes if
                    270: .Fl b
1.34      jmc       271: is specified).
1.87    ! remi      272: .It Fl R
        !           273: List all rdomains with associated interfaces and routing tables.
1.1       deraadt   274: .It Fl r
                    275: Show the routing tables.
1.86      jmc       276: The output is explained in more detail below.
1.21      aaron     277: If the
1.1       deraadt   278: .Fl s
1.21      aaron     279: option is also specified, show routing statistics instead.
1.60      sobrado   280: When used with the
                    281: .Fl v
                    282: option, also print routing labels.
1.26      brian     283: .It Fl s
                    284: Show per-protocol statistics.
                    285: If this option is repeated, counters with a value of zero are suppressed.
1.83      kn        286: .It Fl T Ar rtable
1.67      mikeb     287: Select an alternate routing table to query.
                    288: The default is to use the current routing table.
1.31      jmc       289: .It Fl t
                    290: With the
                    291: .Fl i
                    292: option, display the current value of the watchdog timer function.
                    293: .It Fl u
                    294: Limit statistics or address control block reports to the
                    295: .Dv AF_UNIX
                    296: address family.
1.10      peter     297: .It Fl v
1.60      sobrado   298: Show extra (verbose) detail for the routing tables
                    299: .Pq Fl r ,
                    300: or avoid truncation of long addresses.
1.61      bluhm     301: When used with the
                    302: .Fl P
                    303: option, also print socket, domain and protocol specific structures.
1.42      reyk      304: .It Fl W Ar interface
                    305: (IEEE 802.11 devices only)
                    306: Show per-interface IEEE 802.11 wireless statistics.
1.1       deraadt   307: .It Fl w Ar wait
                    308: Show network interface statistics at intervals of
                    309: .Ar wait
                    310: seconds.
                    311: .El
                    312: .Pp
                    313: The default display, for active sockets, shows the local
                    314: and remote addresses, send and receive queue sizes (in bytes), protocol,
                    315: and the internal state of the protocol.
1.21      aaron     316: .Pp
                    317: Address formats are of the form
                    318: .Dq host.port
                    319: or
                    320: .Dq network.port
1.1       deraadt   321: if a socket's address specifies a network but no specific host address.
1.72      schwarze  322: When known, the host addresses are displayed symbolically
                    323: according to the
                    324: .Xr hosts 5
                    325: database.
1.21      aaron     326: If a symbolic name for an address is unknown, or if the
1.1       deraadt   327: .Fl n
                    328: option is specified, the address is printed numerically, according
                    329: to the address family.
1.21      aaron     330: .Pp
                    331: For more information regarding the Internet
                    332: .Dq dot format ,
1.1       deraadt   333: refer to
1.71      jmc       334: .Xr inet_ntop 3 .
1.34      jmc       335: Unspecified or
1.21      aaron     336: .Dq wildcard
                    337: addresses and ports appear as a single
1.34      jmc       338: .Sq * .
1.6       deraadt   339: If a local port number is registered as being in use for RPC by
1.12      aaron     340: .Xr portmap 8 ,
1.11      aaron     341: its RPC service name or RPC service number will be printed in
1.21      aaron     342: .Dq []
                    343: immediately after the port number.
1.1       deraadt   344: .Pp
                    345: The interface display provides a table of cumulative
                    346: statistics regarding packets transferred, errors, and collisions.
                    347: The network addresses of the interface
1.21      aaron     348: and the maximum transmission unit (MTU) are also displayed.
1.1       deraadt   349: .Pp
1.21      aaron     350: The routing table display indicates the available routes and their status.
                    351: Each route consists of a destination host or network and
                    352: a gateway to use in forwarding packets.
                    353: If the destination is a
                    354: network in numeric format, the netmask (in /24 style format) is appended.
                    355: The flags field shows a collection of information about
                    356: the route stored as binary choices.
                    357: The individual flags are discussed in more detail in the
1.1       deraadt   358: .Xr route 8
                    359: and
                    360: .Xr route 4
                    361: manual pages.
1.21      aaron     362: .Pp
1.1       deraadt   363: The mapping between letters and flags is:
1.66      jmc       364: .Bl -column "1" "RTF_BLACKHOLE" "Protocol specific routing flag #1."
                    365: .It 1 Ta RTF_PROTO1 Ta "Protocol specific routing flag #1."
                    366: .It 2 Ta RTF_PROTO2 Ta "Protocol specific routing flag #2."
                    367: .It 3 Ta RTF_PROTO3 Ta "Protocol specific routing flag #3."
                    368: .It B Ta RTF_BLACKHOLE Ta "Just discard pkts (during updates)."
1.70      mpi       369: .It b Ta RTF_BROADCAST Ta "Correspond to a local broadcast address."
1.66      jmc       370: .It C Ta RTF_CLONING Ta "Generate new routes on use."
                    371: .It c Ta RTF_CLONED Ta "Cloned routes (generated from RTF_CLONING)."
                    372: .It D Ta RTF_DYNAMIC Ta "Created dynamically (by redirect)."
1.79      bluhm     373: .It d Ta RTF_DONE Ta "Completed (for routing messages only)."
1.66      jmc       374: .It G Ta RTF_GATEWAY Ta "Destination requires forwarding by intermediary."
                    375: .It H Ta RTF_HOST Ta "Host entry (net otherwise)."
1.79      bluhm     376: .It h Ta RTF_CACHED Ta "Referenced by gateway route."
1.66      jmc       377: .It L Ta RTF_LLINFO Ta "Valid protocol to link address translation."
1.70      mpi       378: .It l Ta RTF_LOCAL Ta "Correspond to a local address."
1.66      jmc       379: .It M Ta RTF_MODIFIED Ta "Modified dynamically (by redirect)."
1.78      mpi       380: .It m Ta RTF_MULTICAST Ta "Correspond to a multicast address."
1.79      bluhm     381: .It n Ta RTF_CONNECTED Ta "Interface route."
1.66      jmc       382: .It P Ta RTF_MPATH Ta "Multipath route."
                    383: .It R Ta RTF_REJECT Ta "Host or net unreachable."
                    384: .It S Ta RTF_STATIC Ta "Manually added."
                    385: .It T Ta RTF_MPLS Ta "MPLS route."
                    386: .It U Ta RTF_UP Ta "Route usable."
1.1       deraadt   387: .El
                    388: .Pp
1.21      aaron     389: Direct routes are created for each interface attached to the local host;
1.1       deraadt   390: the gateway field for such entries shows the address of the outgoing interface.
1.21      aaron     391: The refcnt field gives the current number of active uses of the route.
                    392: Connection oriented protocols normally hold on to a single route for the
                    393: duration of a connection while connectionless protocols obtain a route while
                    394: sending to the same destination.
                    395: The use field provides a count of the number of packets sent using that route.
                    396: The MTU entry shows the MTU associated with that route.
                    397: This MTU value is used as the basis for the TCP maximum segment size (MSS).
1.34      jmc       398: The
                    399: .Sq L
                    400: flag appended to the MTU value indicates that the value is
                    401: locked, and that path MTU discovery is turned off for that route.
1.21      aaron     402: A
1.1       deraadt   403: .Sq -
1.12      aaron     404: indicates that the MTU for this route has not been set, and a default
1.21      aaron     405: TCP maximum segment size will be used.
                    406: The interface entry indicates the network interface utilized for the route.
1.1       deraadt   407: .Pp
                    408: When
1.21      aaron     409: .Nm
1.1       deraadt   410: is invoked with the
                    411: .Fl w
                    412: option and a
                    413: .Ar wait
                    414: interval argument, it displays a running count of statistics related to
                    415: network interfaces.
                    416: An obsolescent version of this option used a numeric parameter
                    417: with no option, and is currently supported for backward compatibility.
                    418: This display consists of a column for the primary interface (the first
                    419: interface found during autoconfiguration) and a column summarizing
                    420: information for all interfaces.
                    421: The primary interface may be replaced with another interface with the
                    422: .Fl I
                    423: option.
                    424: The first line of each screen of information contains a summary since the
1.21      aaron     425: system was last rebooted.
                    426: Subsequent lines of output show values accumulated over the preceding interval.
1.1       deraadt   427: .Sh SEE ALSO
1.47      jmc       428: .Xr fstat 1 ,
1.1       deraadt   429: .Xr nfsstat 1 ,
                    430: .Xr ps 1 ,
1.47      jmc       431: .Xr systat 1 ,
1.53      jmc       432: .Xr tcpbench 1 ,
1.47      jmc       433: .Xr top 1 ,
1.71      jmc       434: .Xr inet_ntop 3 ,
1.21      aaron     435: .Xr netintro 4 ,
1.34      jmc       436: .Xr route 4 ,
1.1       deraadt   437: .Xr hosts 5 ,
                    438: .Xr protocols 5 ,
                    439: .Xr services 5 ,
1.15      alex      440: .Xr iostat 8 ,
1.34      jmc       441: .Xr portmap 8 ,
1.47      jmc       442: .Xr pstat 8 ,
1.34      jmc       443: .Xr route 8 ,
1.40      jmc       444: .Xr tcpdrop 8 ,
1.1       deraadt   445: .Xr trpt 8 ,
                    446: .Xr vmstat 8
                    447: .Sh HISTORY
                    448: The
1.21      aaron     449: .Nm
1.1       deraadt   450: command appeared in
                    451: .Bx 4.2 .
1.62      schwarze  452: IPv6 support was added by the WIDE/KAME project.
1.1       deraadt   453: .Sh BUGS
                    454: The notion of errors is ill-defined.