1.\" $NetBSD: netstat.1,v 1.31 2001/05/28 05:52:41 itojun Exp $ 2.\" 3.\" Copyright (c) 1983, 1990, 1992, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94 35.\" 36.Dd December 13, 1999 37.Dt NETSTAT 1 38.Os 39.Sh NAME 40.Nm netstat 41.Nd show network status 42.Sh SYNOPSIS 43.Nm 44.Op Fl Aan 45.Op Fl f Ar address_family 46.Op Fl M Ar core 47.Op Fl N Ar system 48.Nm "" 49.Op Fl dgiLmnrsSv 50.Op Fl f Ar address_family 51.Op Fl M Ar core 52.Op Fl N Ar system 53.Nm "" 54.Op Fl dn 55.Op Fl I Ar interface 56.Op Fl M Ar core 57.Op Fl N Ar system 58.Op Fl w Ar wait 59.Nm "" 60.Op Fl p Ar protocol 61.Op Fl M Ar core 62.Op Fl N Ar system 63.Nm "" 64.Op Fl p Ar protocol 65.Op Fl M Ar core 66.Op Fl N Ar system 67.Fl P Ar pcbaddr 68.Nm "" 69.Op Fl p Ar protocol 70.Op Fl i 71.Op Fl I Ar Interface 72.Nm "" 73.Op Fl s 74.Op Fl f Ar address_family 75.Op Fl i 76.Op Fl I Ar Interface 77.Sh DESCRIPTION 78The 79.Nm 80command symbolically displays the contents of various network-related 81data structures. 82There are a number of output formats, 83depending on the options for the information presented. 84The first form of the command displays a list of active sockets for 85each protocol. 86The second form presents the contents of one of the other network 87data structures according to the option selected. 88Using the third form, with a 89.Ar wait 90interval specified, 91.Nm 92will continuously display the information regarding packet 93traffic on the configured network interfaces. 94The fourth form displays statistics about the named protocol. 95The fifth and sixth forms display per interface statistics for 96the specified protocol or address family. 97.Pp 98The options have the following meaning: 99.Bl -tag -width flag 100.It Fl A 101With the default display, 102show the address of any protocol control blocks associated with sockets; used 103for debugging. 104.It Fl a 105With the default display, 106show the state of all sockets; normally sockets used by 107server processes are not shown. 108.It Fl b 109With the interface display (option 110.Fl i ) , 111show bytes in and out, instead of packets in and out. 112.It Fl d 113With either interface display (option 114.Fl i 115or an interval, as described below), 116show the number of dropped packets. 117.It Fl f Ar address_family 118Limit statistics or address control block reports to those 119of the specified 120.Ar address family . 121The following address families 122are recognized: 123.Ar inet , 124for 125.Dv AF_INET ; 126.Ar inet6 , 127for 128.Dv AF_INET6 ; 129.Ar arp , 130for 131.Dv AF_ARP ; 132.Ar ns , 133for 134.Dv AF_NS ; 135.Ar iso , 136for 137.Dv AF_ISO ; 138.Ar atalk , 139for 140.Dv AF_APPLETALK ; 141and 142.Ar local 143or 144.Ar unix , 145for 146.Dv AF_LOCAL . 147.It Fl g 148Show information related to multicast (group address) routing. 149By default, show the IP Multicast virtual-interface and routing tables. 150If the 151.Fl s 152option is also present, show multicast routing statistics. 153.It Fl I Ar interface 154Show information about the specified interface; 155used with a 156.Ar wait 157interval as described below. 158If the 159.Fl f Ar address_family 160option (with the 161.Fl s 162option) or the 163.Fl p Ar protocol 164option is present, show per-interface statistics on the 165.Ar interface 166for the specified 167.Ar address_family 168or 169.Ar protocol , 170respectively. 171.It Fl i 172Show the state of interfaces which have been auto-configured 173(interfaces statically configured into a system, but not 174located at boot time are not shown). 175If the 176.Fl a 177options is also present, multicast addresses currently in use are shown 178for each Ethernet interface and for each IP interface address. 179Multicast addresses are shown on separate lines following the interface 180address with which they are associated. 181If the 182.Fl f Ar address_family 183option (with the 184.Fl s 185option) or the 186.Fl p Ar protocol 187option is present, show per-interface statistics on all interfaces 188for the specified 189.Ar address_family 190or 191.Ar protocol , 192respectively. 193.It Fl L 194Don't show link-level routes (e.g., IPv4 ARP or IPv6 neighbour cache). 195.It Fl M 196Extract values associated with the name list from the specified core 197instead of the default 198.Pa /dev/kmem . 199.It Fl m 200Show statistics recorded by the memory management routines 201(the network manages a private pool of memory buffers). 202.It Fl N 203Extract the name list from the specified system instead of the default 204.Pa /netbsd . 205.It Fl n 206Show network addresses and ports as numbers (normally 207.Nm 208interprets addresses and ports and attempts to display them 209symbolically). 210This option may be used with any of the display formats. 211.It Fl S 212Show network addresses as numbers (as with 213.Fl n ) 214but show ports symbolically). 215.It Fl P Ar pcbaddr 216Dump the contents of the protocol control block (PCB) located at kernel 217virtual address 218.Ar pcbaddr . 219This address may be obtained using the 220.Fl A 221flag. The default protocol is TCP, but may be overridden using the 222.Fl p 223flag. 224.It Fl p Ar protocol 225Show statistics about 226.Ar protocol , 227which is either a well-known name for a protocol or an alias for it. Some 228protocol names and aliases are listed in the file 229.Pa /etc/protocols . 230A null response typically means that there are no interesting numbers to 231report. 232The program will complain if 233.Ar protocol 234is unknown or if there is no statistics routine for it. 235.It Fl s 236Show per-protocol statistics. 237If this option is repeated, counters with a value of zero are suppressed. 238.It Fl r 239Show the routing tables. 240When 241.Fl s 242is also present, show routing statistics instead. 243.It Fl v 244Show extra (verbose) detail for the routing tables 245.Pq Fl r , 246or avoid truncation of long addresses. 247.It Fl w Ar wait 248Show network interface statistics at intervals of 249.Ar wait 250seconds. 251.El 252.Pp 253The default display, for active sockets, shows the local 254and remote addresses, send and receive queue sizes (in bytes), protocol, 255and the internal state of the protocol. 256Address formats are of the form ``host.port'' or ``network.port'' 257if a socket's address specifies a network but no specific host address. 258When known the host and network addresses are displayed symbolically 259according to the data bases 260.Pa /etc/hosts 261and 262.Pa /etc/networks , 263respectively. If a symbolic name for an address is unknown, or if 264the 265.Fl n 266option is specified, the address is printed numerically, according 267to the address family. 268For more information regarding 269the Internet ``dot format,'' 270refer to 271.Xr inet 3 ) . 272Unspecified, 273or ``wildcard'', addresses and ports appear as ``*''. 274.Pp 275The interface display provides a table of cumulative 276statistics regarding packets transferred, errors, and collisions. 277The network addresses of the interface 278and the maximum transmission unit (``mtu'') are also displayed. 279.Pp 280The routing table display indicates the available routes and 281their status. Each route consists of a destination host or network 282and a gateway to use in forwarding packets. The flags field shows 283a collection of information about the route stored as 284binary choices. The individual flags are discussed in more 285detail in the 286.Xr route 8 287and 288.Xr route 4 289manual pages. 290The mapping between letters and flags is: 291.Bl -column XXXX RTF_BLACKHOLE 2921 RTF_PROTO2 Protocol specific routing flag #1 2932 RTF_PROTO1 Protocol specific routing flag #2 294B RTF_BLACKHOLE Just discard pkts (during updates) 295C RTF_CLONING Generate new routes on use 296c RTF_CLONED Cloned routes (generated from RTF_CLONING) 297D RTF_DYNAMIC Created dynamically (by redirect) 298G RTF_GATEWAY Destination requires forwarding by intermediary 299H RTF_HOST Host entry (net otherwise) 300L RTF_LLINFO Valid protocol to link address translation. 301M RTF_MODIFIED Modified dynamically (by redirect) 302R RTF_REJECT Host or net unreachable 303S RTF_STATIC Manually added 304U RTF_UP Route usable 305X RTF_XRESOLVE External daemon translates proto to link address 306.El 307.Pp 308Direct routes are created for each 309interface attached to the local host; 310the gateway field for such entries shows the address of the outgoing interface. 311The refcnt field gives the 312current number of active uses of the route. Connection oriented 313protocols normally hold on to a single route for the duration of 314a connection while connectionless protocols obtain a route while sending 315to the same destination. 316The use field provides a count of the number of packets 317sent using that route. The mtu entry shows the mtu associated with 318that route. This mtu value is used as the basis for the TCP maximum 319segment size. The 'L' flag appended to the mtu value indicates that 320the value is locked, and that path mtu discovery is turned off for 321that route. 322A 323.Sq - 324indicates that the mtu for this route has not been set, and a default 325TCP maximum segment size will be used. The interface entry indicates 326the network interface utilized for the route. 327.Pp 328When 329.Nm 330is invoked with the 331.Fl w 332option and a 333.Ar wait 334interval argument, it displays a running count of statistics related to 335network interfaces. 336An obsolescent version of this option used a numeric parameter 337with no option, and is currently supported for backward compatibility. 338This display consists of a column for the primary interface (the first 339interface found during autoconfiguration) and a column summarizing 340information for all interfaces. 341The primary interface may be replaced with another interface with the 342.Fl I 343option. 344The first line of each screen of information contains a summary since the 345system was last rebooted. Subsequent lines of output show values 346accumulated over the preceding interval. 347.Sh SEE ALSO 348.Xr nfsstat 1 , 349.Xr ps 1 , 350.Xr vmstat 1 , 351.Xr hosts 5 , 352.Xr networks 5 , 353.Xr protocols 5 , 354.Xr services 5 , 355.Xr iostat 8 , 356.Xr trpt 8 , 357.Xr trsp 8 358.Sh HISTORY 359The 360.Nm 361command appeared in 362.Bx 4.2 . 363IPv6 support was added by WIDE/KAME project. 364.\" .Sh FILES 365.\" .Bl -tag -width /dev/kmem -compact 366.\" .It Pa /netbsd 367.\" default kernel namelist 368.\" .It Pa /dev/kmem 369.\" default memory file 370.\" .El 371.Sh BUGS 372The notion of errors is ill-defined. 373