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