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. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94 33.\" 34.Dd April 18, 1994 35.Dt NETSTAT 1 36.Os BSD 4.2 37.Sh NAME 38.Nm netstat 39.Nd show network status 40.Sh SYNOPSIS 41.Nm netstat 42.Op Fl Aan 43.Op Fl f Ar address_family 44.Op Fl M Ar core 45.Op Fl N Ar system 46.Nm netstat 47.Op Fl bdghimnrs 48.Op Fl f Ar address_family 49.Op Fl M Ar core 50.Op Fl N Ar system 51.Nm netstat 52.Op Fl bdn 53.Op Fl I Ar interface 54.Op Fl M Ar core 55.Op Fl N Ar system 56.Op Fl w Ar wait 57.Nm netstat 58.Op Fl p Ar protocol 59.Op Fl M Ar core 60.Op Fl N Ar system 61.Sh DESCRIPTION 62The 63.Nm netstat 64command symbolically displays the contents of various network-related 65data structures. 66There are a number of output formats, 67depending on the options for the information presented. 68The first form of the command displays a list of active sockets for 69each protocol. 70The second form presents the contents of one of the other network 71data structures according to the option selected. 72Using the third form, with a 73.Ar wait 74interval specified, 75.Nm netstat 76will continuously display the information regarding packet 77traffic on the configured network interfaces. 78The fourth form displays statistics about the named protocol. 79.Pp 80The options have the following meaning: 81.Bl -tag -width flag 82.It Fl A 83With the default display, 84show the address of any protocol control blocks associated with sockets; used 85for debugging. 86.It Fl a 87With the default display, 88show the state of all sockets; normally sockets used by 89server processes are not shown. 90.It Fl b 91With the interface display (option 92.Fl i 93, as described below), 94show the number of bytes in and out. 95.It Fl d 96With either interface display (option 97.Fl i 98or an interval, as described below), 99show the number of dropped packets. 100.It Fl f Ar address_family 101Limit statistics or address control block reports to those 102of the specified 103.Ar address family . 104The following address families 105are recognized: 106.Ar inet , 107for 108.Dv AF_INET , 109.Ar ipx , 110for 111.Dv AF_IPX , 112.Ar atalk , 113for 114.Dv AF_APPLETALK (ddp) , 115.\".Ar ns , 116.\"for 117.\".Dv AF_NS , 118.\".Ar iso , 119.\"for 120.\".Dv AF_ISO , 121and 122.Ar unix , 123for 124.Dv AF_UNIX . 125.It Fl g 126Show information related to multicast (group address) routing. 127By default, show the IP Multicast virtual-interface and routing tables. 128If the 129.Fl s 130option is also present, show multicast routing statistics. 131.It Fl h 132Show the state of the 133.Tn IMP 134host table (obsolete). 135.It Fl I Ar interface 136Show information about the specified interface; 137used with a 138.Ar wait 139interval as described below. 140.It Fl i 141Show the state of interfaces which have been auto-configured 142(interfaces statically configured into a system, but not 143located at boot time are not shown). 144If the 145.Fl a 146options is also present, multicast addresses currently in use are shown 147for each Ethernet interface and for each IP interface address. 148Multicast addresses are shown on separate lines following the interface 149address with which they are associated. 150.It Fl M 151Extract values associated with the name list from the specified core 152instead of the default 153.Pa /dev/kmem . 154.It Fl m 155Show statistics recorded by the memory management routines 156(the network manages a private pool of memory buffers). 157.It Fl N 158Extract the name list from the specified system instead of the default 159.Pa /kernel . 160.It Fl n 161Show network addresses as numbers (normally 162.Nm netstat 163interprets addresses and attempts to display them 164symbolically). 165This option may be used with any of the display formats. 166.It Fl p Ar protocol 167Show statistics about 168.Ar protocol , 169which is either a well-known name for a protocol or an alias for it. Some 170protocol names and aliases are listed in the file 171.Pa /etc/protocols . 172A null response typically means that there are no interesting numbers to 173report. 174The program will complain if 175.Ar protocol 176is unknown or if there is no statistics routine for it. 177.It Fl s 178Show per-protocol statistics. 179If this option is repeated, counters with a value of zero are suppressed. 180.It Fl r 181Show the routing tables. 182When 183.Fl s 184is also present, show routing statistics instead. 185.It Fl w Ar wait 186Show network interface statistics at intervals of 187.Ar wait 188seconds. 189.El 190.Pp 191The default display, for active sockets, shows the local 192and remote addresses, send and receive queue sizes (in bytes), protocol, 193and the internal state of the protocol. 194Address formats are of the form ``host.port'' or ``network.port'' 195if a socket's address specifies a network but no specific host address. 196When known the host and network addresses are displayed symbolically 197according to the data bases 198.Pa /etc/hosts 199and 200.Pa /etc/networks , 201respectively. If a symbolic name for an address is unknown, or if 202the 203.Fl n 204option is specified, the address is printed numerically, according 205to the address family. 206For more information regarding 207the Internet ``dot format,'' 208refer to 209.Xr inet 3 ) . 210Unspecified, 211or ``wildcard'', addresses and ports appear as ``*''. 212.Pp 213The interface display provides a table of cumulative 214statistics regarding packets transferred, errors, and collisions. 215The network addresses of the interface 216and the maximum transmission unit (``mtu'') are also displayed. 217.Pp 218The routing table display indicates the available routes and 219their status. Each route consists of a destination host or network 220and a gateway to use in forwarding packets. The flags field shows 221a collection of information about the route stored as 222binary choices. The individual flags are discussed in more 223detail in the 224.Xr route 8 225and 226.Xr route 4 227manual pages. 228The mapping between letters and flags is: 229.Bl -column XXXX RTF_BLACKHOLE 2301 RTF_PROTO2 Protocol specific routing flag #1 2312 RTF_PROTO1 Protocol specific routing flag #2 2323 RTF_PROTO3 Protocol specific routing flag #3 233B RTF_BLACKHOLE Just discard pkts (during updates) 234b RTF_BROADCAST The route represents a broadcast address 235C RTF_CLONING Generate new routes on use 236c RTF_PRCLONING Protocol-specified generate new routes on use 237D RTF_DYNAMIC Created dynamically (by redirect) 238G RTF_GATEWAY Destination requires forwarding by intermediary 239H RTF_HOST Host entry (net otherwise) 240L RTF_LLINFO Valid protocol to link address translation 241M RTF_MODIFIED Modified dynamically (by redirect) 242R RTF_REJECT Host or net unreachable 243S RTF_STATIC Manually added 244U RTF_UP Route usable 245W RTF_WASCLONED Route was generated as a result of cloning 246X RTF_XRESOLVE External daemon translates proto to link address 247.El 248.Pp 249Direct routes are created for each 250interface attached to the local host; 251the gateway field for such entries shows the address of the outgoing interface. 252The refcnt field gives the 253current number of active uses of the route. Connection oriented 254protocols normally hold on to a single route for the duration of 255a connection while connectionless protocols obtain a route while sending 256to the same destination. 257The use field provides a count of the number of packets 258sent using that route. The interface entry indicates the network 259interface utilized for the route. 260.Pp 261When 262.Nm netstat 263is invoked with the 264.Fl w 265option and a 266.Ar wait 267interval argument, it displays a running count of statistics related to 268network interfaces. 269An obsolescent version of this option used a numeric parameter 270with no option, and is currently supported for backward compatibility. 271By default, this display summarizes information for all interfaces. 272Information for a specific interface may be displayed with the 273.Fl I 274option. 275.Sh SEE ALSO 276.Xr nfsstat 1 , 277.Xr ps 1 , 278.Xr hosts 5 , 279.Xr networks 5 , 280.Xr protocols 5 , 281.Xr services 5 , 282.Xr iostat 8 , 283.Xr trpt 8 , 284.Xr trsp 8 , 285.Xr vmstat 8 286.Sh HISTORY 287The 288.Nm netstat 289command appeared in 290.Bx 4.2 . 291.\" .Sh FILES 292.\" .Bl -tag -width /dev/kmem -compact 293.\" .It Pa /kernel 294.\" default kernel namelist 295.\" .It Pa /dev/kmem 296.\" default memory file 297.\" .El 298.Sh BUGS 299The notion of errors is ill-defined. 300