1.\" Copyright (c) 1983, 1990 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)netstat.1 6.14 (Berkeley) 07/27/91 7.\" 8.Dd 9.Dt NETSTAT 1 10.Os BSD 4.2 11.Sh NAME 12.Nm netstat 13.Nd show network status 14.Sh SYNOPSIS 15.Nm netstat 16.Op Fl Aan 17.Op Fl f Ar address_family 18.Op Ar system 19.Op Ar core 20.Nm netstat 21.Op Fl himnrs 22.Op Fl f Ar address_family 23.Op Fl M Ar core 24.Op Fl N Ar system 25.Nm netstat 26.Op Fl n 27.Op Fl I Op Ar interface 28.Op Fl M Ar core 29.Op Fl N Ar system 30.Op Fl w Ar wait 31.Nm netstat 32.Op Fl p Ar protocol 33.Op Fl M Ar core 34.Op Fl N Ar system 35.Sh DESCRIPTION 36The 37.Nm netstat 38command symbolically displays the contents of various network-related 39data structures. 40There are a number of output formats, 41depending on the options for the information presented. 42The first form of the command displays a list of active sockets for 43each protocol. 44The second form presents the contents of one of the other network 45data structures according to the option selected. 46Using the third form, with a 47.Ar wait 48interval specified, 49.Nm netstat 50will continuously display the information regarding packet 51traffic on the configured network interfaces. 52The fourth form displays statistics about the named protocol. 53.Pp 54The options have the following meaning: 55.Bl -tag -width flag 56.It Fl A 57With the default display, 58show the address of any protocol control blocks associated with sockets; used 59for debugging. 60.It Fl a 61With the default display, 62show the state of all sockets; normally sockets used by 63server processes are not shown. 64.It Fl d 65With either interface display (option 66.Fl i 67or an interval, as described below), 68show the number of dropped packets. 69.It Fl h 70Show the state of the 71.Tn IMP 72host table. 73.It Fl i 74Show the state of interfaces which have been auto-configured 75(interfaces statically configured into a system, but not 76located at boot time are not shown). 77.It Fl I Ar interface 78Show information only about this interface; 79used with an 80.Ar wait 81interval as described below. 82.It Fl M 83Extract values associated with the name list from the specified core 84instead of the default 85.Pa /dev/kmem . 86.It Fl m 87Show statistics recorded by the memory management routines 88(the network manages a private pool of memory buffers). 89.It Fl N 90Extract the name list from the specified system instead of the default 91.Pa /vmunix . 92.It Fl n 93Show network addresses as numbers (normally 94.Nm netstat 95interprets addresses and attempts to display them 96symbolically). 97This option may be used with any of the display formats. 98.It Fl p Ar protocol 99Show statistics about 100.Ar protocol , 101which is either a well-known name for a protocol or an alias for it. Some 102protocol names and aliases are listed in the file 103.Pa /etc/protocols . 104A null response typically means that there are no interesting numbers to 105report. 106The program will complain if 107.Ar protocol 108is unknown or if there is no statistics routine for it. 109.It Fl s 110Show per-protocol statistics. 111.It Fl r 112Show the routing tables. 113When 114.Fl s 115is also present, show routing statistics instead. 116.It Fl f Ar address_family 117Limit statistics or address control block reports to those 118of the specified 119.Ar address family . 120The following address families 121are recognized: 122.Ar inet , 123for 124.Dv AF_INET , 125.Ar ns , 126for 127.Dv AF_NS , 128and 129.Ar unix , 130for 131.Dv AF_UNIX . 132.El 133.Pp 134The default display, for active sockets, shows the local 135and remote addresses, send and receive queue sizes (in bytes), protocol, 136and the internal state of the protocol. 137Address formats are of the form ``host.port'' or ``network.port'' 138if a socket's address specifies a network but no specific host address. 139When known the host and network addresses are displayed symbolically 140according to the data bases 141.Pa /etc/hosts 142and 143.Pa /etc/networks , 144respectively. If a symbolic name for an address is unknown, or if 145the 146.Fl n 147option is specified, the address is printed numerically, according 148to the address family. 149For more information regarding 150the Internet ``dot format,'' 151refer to 152.Xr inet 3 ) . 153Unspecified, 154or ``wildcard'', addresses and ports appear as ``*''. 155.Pp 156The interface display provides a table of cumulative 157statistics regarding packets transferred, errors, and collisions. 158The network addresses of the interface 159and the maximum transmission unit (``mtu'') are also displayed. 160.Pp 161The routing table display indicates the available routes and 162their status. Each route consists of a destination host or network 163and a gateway to use in forwarding packets. The flags field shows 164the state of the route (``U'' if ``up''), whether the route 165is to a gateway (``G''), whether the route was created dynamically 166by a redirect (``D''), and whether the route has been modified 167by a redirect (``M''). Direct routes are created for each 168interface attached to the local host; 169the gateway field for such entries shows the address of the outgoing interface. 170The refcnt field gives the 171current number of active uses of the route. Connection oriented 172protocols normally hold on to a single route for the duration of 173a connection while connectionless protocols obtain a route while sending 174to the same destination. 175The use field provides a count of the number of packets 176sent using that route. The interface entry indicates the network 177interface utilized for the route. 178.Pp 179When 180.Nm netstat 181is invoked with a 182.Ar wait 183interval argument, it displays a running count of statistics related to 184network interfaces. 185This display consists of a column for the primary interface (the first 186interface found during autoconfiguration) and a column summarizing 187information for all interfaces. 188The primary interface may be replaced with another interface with the 189.Fl I 190option. 191The first line of each screen of information contains a summary since the 192system was last rebooted. Subsequent lines of output show values 193accumulated over the preceding interval. 194.Sh SEE ALSO 195.Xr iostat 1 , 196.Xr nfsstat 1 , 197.Xr ps 1 , 198.Xr vmstat 1 , 199.Xr hosts 5 , 200.Xr networks 5 , 201.Xr protocols 5 , 202.Xr services 5 , 203.Xr trpt 8 , 204.Xr trsp 8 205.Sh HISTORY 206The 207.Nm netstat 208command appeared in 209.Bx 4.2 . 210.\" .Sh FILES 211.\" .Bl -tag -width /dev/kmem -compact 212.\" .It Pa /vmunix 213.\" default kernel namelist 214.\" .It Pa /dev/kmem 215.\" default memory file 216.\" .El 217.Sh BUGS 218The notion of errors is ill-defined. 219.Pp 220Collisions mean something else for the 221.Tn IMP . 222