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.\" from: @(#)netstat.1 8.8 (Berkeley) 4/18/94 33.\" $Id: netstat.1,v 1.7 1994/08/06 06:20:30 jtc Exp $ 34.\" 35.Dd April 18, 1994 36.Dt NETSTAT 1 37.Os BSD 4.2 38.Sh NAME 39.Nm netstat 40.Nd show network status 41.Sh SYNOPSIS 42.Nm netstat 43.Op Fl Aan 44.Op Fl f Ar address_family 45.Op Fl M Ar core 46.Op Fl N Ar system 47.Nm netstat 48.Op Fl dghimnrs 49.Op Fl f Ar address_family 50.Op Fl M Ar core 51.Op Fl N Ar system 52.Nm netstat 53.Op Fl dn 54.Op Fl I Ar interface 55.Op Fl M Ar core 56.Op Fl N Ar system 57.Op Fl w Ar wait 58.Nm netstat 59.Op Fl p Ar protocol 60.Op Fl M Ar core 61.Op Fl N Ar system 62.Sh DESCRIPTION 63The 64.Nm netstat 65command symbolically displays the contents of various network-related 66data structures. 67There are a number of output formats, 68depending on the options for the information presented. 69The first form of the command displays a list of active sockets for 70each protocol. 71The second form presents the contents of one of the other network 72data structures according to the option selected. 73Using the third form, with a 74.Ar wait 75interval specified, 76.Nm netstat 77will continuously display the information regarding packet 78traffic on the configured network interfaces. 79The fourth form displays statistics about the named protocol. 80.Pp 81The options have the following meaning: 82.Bl -tag -width flag 83.It Fl A 84With the default display, 85show the address of any protocol control blocks associated with sockets; used 86for debugging. 87.It Fl a 88With the default display, 89show the state of all sockets; normally sockets used by 90server processes are not shown. 91.It Fl d 92With either interface display (option 93.Fl i 94or an interval, as described below), 95show the number of dropped packets. 96.It Fl f Ar address_family 97Limit statistics or address control block reports to those 98of the specified 99.Ar address family . 100The following address families 101are recognized: 102.Ar inet , 103for 104.Dv AF_INET , 105.Ar ns , 106for 107.Dv AF_NS , 108.Ar iso , 109for 110.Dv AF_ISO , 111and 112.Ar unix , 113for 114.Dv AF_UNIX . 115.It Fl g 116Show information related to multicast (group address) routing. 117By default, show the IP Multicast virtual-interface and routing tables. 118If the 119.Fl s 120option is also present, show multicast routing statistics. 121.It Fl h 122Show the state of the 123.Tn IMP 124host table (obsolete). 125.It Fl I Ar interface 126Show information about the specified interface; 127used with a 128.Ar wait 129interval as described below. 130.It Fl i 131Show the state of interfaces which have been auto-configured 132(interfaces statically configured into a system, but not 133located at boot time are not shown). 134If the 135.Fl a 136options is also present, multicast addresses currently in use are shown 137for each Ethernet interface and for each IP interface address. 138Multicast addresses are shown on separate lines following the interface 139address with which they are associated. 140.It Fl M 141Extract values associated with the name list from the specified core 142instead of the default 143.Pa /dev/kmem . 144.It Fl m 145Show statistics recorded by the memory management routines 146(the network manages a private pool of memory buffers). 147.It Fl N 148Extract the name list from the specified system instead of the default 149.Pa /netbsd . 150.It Fl n 151Show network addresses as numbers (normally 152.Nm netstat 153interprets addresses and attempts to display them 154symbolically). 155This option may be used with any of the display formats. 156.It Fl p Ar protocol 157Show statistics about 158.Ar protocol , 159which is either a well-known name for a protocol or an alias for it. Some 160protocol names and aliases are listed in the file 161.Pa /etc/protocols . 162A null response typically means that there are no interesting numbers to 163report. 164The program will complain if 165.Ar protocol 166is unknown or if there is no statistics routine for it. 167.It Fl s 168Show per-protocol statistics. 169If this option is repeated, counters with a value of zero are suppressed. 170.It Fl r 171Show the routing tables. 172When 173.Fl s 174is also present, show routing statistics instead. 175.It Fl w Ar wait 176Show network interface statistics at intervals of 177.Ar wait 178seconds. 179.El 180.Pp 181The default display, for active sockets, shows the local 182and remote addresses, send and receive queue sizes (in bytes), protocol, 183and the internal state of the protocol. 184Address formats are of the form ``host.port'' or ``network.port'' 185if a socket's address specifies a network but no specific host address. 186When known the host and network addresses are displayed symbolically 187according to the data bases 188.Pa /etc/hosts 189and 190.Pa /etc/networks , 191respectively. If a symbolic name for an address is unknown, or if 192the 193.Fl n 194option is specified, the address is printed numerically, according 195to the address family. 196For more information regarding 197the Internet ``dot format,'' 198refer to 199.Xr inet 3 ) . 200Unspecified, 201or ``wildcard'', addresses and ports appear as ``*''. 202.Pp 203The interface display provides a table of cumulative 204statistics regarding packets transferred, errors, and collisions. 205The network addresses of the interface 206and the maximum transmission unit (``mtu'') are also displayed. 207.Pp 208The routing table display indicates the available routes and 209their status. Each route consists of a destination host or network 210and a gateway to use in forwarding packets. The flags field shows 211a collection of information about the route stored as 212binary choices. The individual flags are discussed in more 213detail in the 214.Xr route 8 215and 216.Xr route 4 217manual pages. 218The mapping between letters and flags is: 219.Bl -column XXXX RTF_BLACKHOLE 2201 RTF_PROTO2 Protocol specific routing flag #1 2212 RTF_PROTO1 Protocol specific routing flag #2 222B RTF_BLACKHOLE Just discard pkts (during updates) 223C RTF_CLONING Generate new routes on use 224D RTF_DYNAMIC Created dynamically (by redirect) 225G RTF_GATEWAY Destination requires forwarding by intermediary 226H RTF_HOST Host entry (net otherwise) 227L RTF_LLINFO Valid protocol to link address translation. 228M RTF_MODIFIED Modified dynamically (by redirect) 229R RTF_REJECT Host or net unreachable 230S RTF_STATIC Manually added 231U RTF_UP Route usable 232X RTF_XRESOLVE External daemon translates proto to link address 233.El 234.Pp 235Direct routes are created for each 236interface attached to the local host; 237the gateway field for such entries shows the address of the outgoing interface. 238The refcnt field gives the 239current number of active uses of the route. Connection oriented 240protocols normally hold on to a single route for the duration of 241a connection while connectionless protocols obtain a route while sending 242to the same destination. 243The use field provides a count of the number of packets 244sent using that route. The interface entry indicates the network 245interface utilized for the route. 246.Pp 247When 248.Nm netstat 249is invoked with the 250.Fl w 251option and a 252.Ar wait 253interval argument, it displays a running count of statistics related to 254network interfaces. 255An obsolescent version of this option used a numeric parameter 256with no option, and is currently supported for backward compatibility. 257This display consists of a column for the primary interface (the first 258interface found during autoconfiguration) and a column summarizing 259information for all interfaces. 260The primary interface may be replaced with another interface with the 261.Fl I 262option. 263The first line of each screen of information contains a summary since the 264system was last rebooted. Subsequent lines of output show values 265accumulated over the preceding interval. 266.Sh SEE ALSO 267.Xr iostat 1 , 268.Xr nfsstat 1 , 269.Xr ps 1 , 270.Xr vmstat 1 , 271.Xr hosts 5 , 272.Xr networks 5 , 273.Xr protocols 5 , 274.Xr services 5 , 275.Xr trpt 8 , 276.Xr trsp 8 277.Sh HISTORY 278The 279.Nm netstat 280command appeared in 281.Bx 4.2 . 282.\" .Sh FILES 283.\" .Bl -tag -width /dev/kmem -compact 284.\" .It Pa /netbsd 285.\" default kernel namelist 286.\" .It Pa /dev/kmem 287.\" default memory file 288.\" .El 289.Sh BUGS 290The notion of errors is ill-defined. 291