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