1.\" $NetBSD: netstat.1,v 1.35 2002/07/03 01:42:59 enami 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 bdgiLmnqrsSv 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 q 236Show software interrupt queue setting/statistics for all protocols. 237.It Fl s 238Show per-protocol statistics. 239If this option is repeated, counters with a value of zero are suppressed. 240.It Fl r 241Show the routing tables. 242When 243.Fl s 244is also present, show routing statistics instead. 245.It Fl v 246Show extra (verbose) detail for the routing tables 247.Pq Fl r , 248or avoid truncation of long addresses. 249.It Fl w Ar wait 250Show network interface statistics at intervals of 251.Ar wait 252seconds. 253.El 254.Pp 255The default display, for active sockets, shows the local 256and remote addresses, send and receive queue sizes (in bytes), protocol, 257and the internal state of the protocol. 258Address formats are of the form ``host.port'' or ``network.port'' 259if a socket's address specifies a network but no specific host address. 260When known the host and network addresses are displayed symbolically 261according to the data bases 262.Pa /etc/hosts 263and 264.Pa /etc/networks , 265respectively. If a symbolic name for an address is unknown, or if 266the 267.Fl n 268option is specified, the address is printed numerically, according 269to the address family. 270For more information regarding 271the Internet ``dot format,'' 272refer to 273.Xr inet 3 ) . 274Unspecified, 275or ``wildcard'', addresses and ports appear as ``*''. 276You can use the 277.Xr fstat 1 278to find out which process or processes hold references to a socket. 279.Pp 280The interface display provides a table of cumulative 281statistics regarding packets transferred, errors, and collisions. 282The network addresses of the interface 283and the maximum transmission unit (``mtu'') are also displayed. 284.Pp 285The routing table display indicates the available routes and 286their status. Each route consists of a destination host or network 287and a gateway to use in forwarding packets. The flags field shows 288a collection of information about the route stored as 289binary choices. The individual flags are discussed in more 290detail in the 291.Xr route 8 292and 293.Xr route 4 294manual pages. 295The mapping between letters and flags is: 296.Bl -column XXXX RTF_BLACKHOLE 2971 RTF_PROTO2 Protocol specific routing flag #1 2982 RTF_PROTO1 Protocol specific routing flag #2 299B RTF_BLACKHOLE Just discard pkts (during updates) 300C RTF_CLONING Generate new routes on use 301c RTF_CLONED Cloned routes (generated from RTF_CLONING) 302D RTF_DYNAMIC Created dynamically (by redirect) 303G RTF_GATEWAY Destination requires forwarding by intermediary 304H RTF_HOST Host entry (net otherwise) 305L RTF_LLINFO Valid protocol to link address translation. 306M RTF_MODIFIED Modified dynamically (by redirect) 307R RTF_REJECT Host or net unreachable 308S RTF_STATIC Manually added 309U RTF_UP Route usable 310X RTF_XRESOLVE External daemon translates proto to link address 311.El 312.Pp 313Direct routes are created for each 314interface attached to the local host; 315the gateway field for such entries shows the address of the outgoing interface. 316The refcnt field gives the 317current number of active uses of the route. Connection oriented 318protocols normally hold on to a single route for the duration of 319a connection while connectionless protocols obtain a route while sending 320to the same destination. 321The use field provides a count of the number of packets 322sent using that route. The mtu entry shows the mtu associated with 323that route. This mtu value is used as the basis for the TCP maximum 324segment size. The 'L' flag appended to the mtu value indicates that 325the value is locked, and that path mtu discovery is turned off for 326that route. 327A 328.Sq - 329indicates that the mtu for this route has not been set, and a default 330TCP maximum segment size will be used. The interface entry indicates 331the network interface utilized for the route. 332.Pp 333When 334.Nm 335is invoked with the 336.Fl w 337option and a 338.Ar wait 339interval argument, it displays a running count of statistics related to 340network interfaces. 341An obsolescent version of this option used a numeric parameter 342with no option, and is currently supported for backward compatibility. 343This display consists of a column for the primary interface (the first 344interface found during autoconfiguration) and a column summarizing 345information for all interfaces. 346The primary interface may be replaced with another interface with the 347.Fl I 348option. 349The first line of each screen of information contains a summary since the 350system was last rebooted. Subsequent lines of output show values 351accumulated over the preceding interval. 352.Sh SEE ALSO 353.Xr fstat 1 , 354.Xr nfsstat 1 , 355.Xr ps 1 , 356.Xr vmstat 1 , 357.Xr inet 3 , 358.Xr hosts 5 , 359.Xr networks 5 , 360.Xr protocols 5 , 361.Xr services 5 , 362.Xr iostat 8 , 363.Xr trpt 8 , 364.Xr trsp 8 365.Sh HISTORY 366The 367.Nm 368command appeared in 369.Bx 4.2 . 370IPv6 support was added by WIDE/KAME project. 371.\" .Sh FILES 372.\" .Bl -tag -width /dev/kmem -compact 373.\" .It Pa /netbsd 374.\" default kernel namelist 375.\" .It Pa /dev/kmem 376.\" default memory file 377.\" .El 378.Sh BUGS 379The notion of errors is ill-defined. 380