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