Annotation of src/usr.bin/netstat/netstat.1, Revision 1.46
1.46 ! jmc 1: .\" $OpenBSD: netstat.1,v 1.45 2005/06/16 16:03:32 jaredy 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.
1.46 ! jmc 89: The fourth form displays statistics about the protocol control block (PCB).
! 90: The fifth form displays statistics about the named protocol.
! 91: The sixth form displays per interface statistics for
1.30 jmc 92: the specified address family.
1.43 jmc 93: The final form displays per interface statistics for
94: the specified wireless (802.11) device.
1.1 deraadt 95: .Pp
1.12 aaron 96: The options are as follows:
1.22 aaron 97: .Bl -tag -width Ds
1.1 deraadt 98: .It Fl A
99: With the default display,
100: show the address of any protocol control blocks associated with sockets; used
1.45 jaredy 101: for debugging, e.g. with the
102: .Fl P
103: flag.
1.1 deraadt 104: .It Fl a
105: With the default display,
106: show the state of all sockets; normally sockets used by
107: server processes are not shown.
1.34 jmc 108: With the interface display (options
109: .Fl I
110: or
111: .Fl i ) ,
112: show multicast addresses.
1.24 camield 113: .It Fl b
1.34 jmc 114: With the interface display (options
115: .Fl I
116: or
1.24 camield 117: .Fl i ) ,
118: show bytes in and out, instead of packet statistics.
1.1 deraadt 119: .It Fl d
1.34 jmc 120: With either the interface display (options
121: .Fl I
122: or
123: .Fl i )
124: or an interval (option
125: .Fl w ) ,
1.1 deraadt 126: show the number of dropped packets.
1.16 aaron 127: .It Fl f Ar address_family
1.1 deraadt 128: Limit statistics or address control block reports to those
129: of the specified
1.12 aaron 130: .Ar address_family .
1.21 aaron 131: .Pp
132: The following address families are recognized:
133: .Pp
134: .Bl -column "Address Family" "AF_APPLETA" "Description" -offset indent -compact
135: .It Sy "Address Family" Ta Sy "Constant" Ta Sy "Description"
1.32 jmc 136: .It "inet" Ta Dv "AF_INET" Ta "IP Version 4"
137: .It "inet6" Ta Dv "AF_INET6" Ta "IP Version 6"
138: .It "ipx" Ta Dv "AF_IPX" Ta "Novell IPX"
139: .It "atalk" Ta Dv "AF_APPLETALK" Ta "AppleTalk"
140: .It "encap" Ta Dv "PF_KEY" Ta "IPsec"
141: .It "local" Ta Dv "AF_LOCAL" Ta "Local to Host (i.e., pipes)"
142: .It "unix" Ta Dv "AF_UNIX" Ta "Local to Host (i.e., pipes)"
1.21 aaron 143: .El
144: .Pp
1.1 deraadt 145: .It Fl g
146: Show information related to multicast (group address) routing.
1.34 jmc 147: By default, show the IP multicast virtual-interface and routing tables.
1.1 deraadt 148: If the
149: .Fl s
150: option is also present, show multicast routing statistics.
1.16 aaron 151: .It Fl I Ar interface
1.21 aaron 152: Show information about the specified
153: .Ar interface ;
1.1 deraadt 154: used with a
155: .Ar wait
156: interval as described below.
1.21 aaron 157: .Pp
1.19 itojun 158: If the
1.34 jmc 159: .Fl a
160: option is also present, multicast addresses currently in use are shown
161: for the given interface and for each IP interface address.
162: Multicast addresses are shown on separate lines following the interface
163: address with which they are associated.
164: .Pp
165: If the
1.19 itojun 166: .Fl f Ar address_family
167: option (with the
168: .Fl s
1.30 jmc 169: option) is present, show per-interface
170: statistics on the given interface for the specified
171: .Ar address_family .
1.1 deraadt 172: .It Fl i
173: Show the state of interfaces which have been auto-configured
1.21 aaron 174: (interfaces statically configured into a system but not
175: located at boot-time are not shown).
176: .Pp
1.1 deraadt 177: If the
178: .Fl a
1.21 aaron 179: option is also present, multicast addresses currently in use are shown
1.1 deraadt 180: for each Ethernet interface and for each IP interface address.
181: Multicast addresses are shown on separate lines following the interface
182: address with which they are associated.
1.21 aaron 183: .Pp
1.19 itojun 184: If the
185: .Fl f Ar address_family
186: option (with the
187: .Fl s
1.30 jmc 188: option) is present, show per-interface statistics on all interfaces
1.21 aaron 189: for the specified
1.30 jmc 190: .Ar address_family .
1.31 jmc 191: .It Fl l
192: With the
193: .Fl g
194: option, display wider fields for the IPv6 multicast routing table
195: .Qq Origin
196: and
197: .Qq Group
198: columns.
1.17 deraadt 199: .It Fl M Ar core
1.1 deraadt 200: Extract values associated with the name list from the specified core
1.27 miod 201: instead of the running kernel.
1.1 deraadt 202: .It Fl m
203: Show statistics recorded by the memory management routines
204: (the network manages a private pool of memory buffers).
1.17 deraadt 205: .It Fl N Ar system
1.27 miod 206: Extract the name list from the specified system instead of the running kernel.
1.1 deraadt 207: .It Fl n
208: Show network addresses as numbers (normally
1.21 aaron 209: .Nm
1.1 deraadt 210: interprets addresses and attempts to display them
211: symbolically).
212: This option may be used with any of the display formats.
1.45 jaredy 213: .It Fl P Ar pcbaddr
214: Display the contents of the protocol control block (PCB) located at
215: the kernel virtual address
216: .Ar pcbaddr .
217: PCB addresses can be obtained using the
218: .Fl A
219: flag.
220: This option can currently only be used to display TCP control blocks.
1.16 aaron 221: .It Fl p Ar protocol
1.35 markus 222: Restrict the output to
1.12 aaron 223: .Ar protocol ,
1.21 aaron 224: which is either a well-known name for a protocol or an alias for it.
225: Some protocol names and aliases are listed in the file
1.1 deraadt 226: .Pa /etc/protocols .
227: The program will complain if
228: .Ar protocol
1.35 markus 229: is unknown.
230: If the
231: .Fl s
232: option is specified, the per-protocol statistics are displayed.
233: Otherwise the states of the matching sockets are shown.
1.26 brian 234: .It Fl q
235: Only show interfaces that have seen packets (or bytes if
236: .Fl b
1.34 jmc 237: is specified).
1.1 deraadt 238: .It Fl r
239: Show the routing tables.
1.21 aaron 240: If the
1.1 deraadt 241: .Fl s
1.21 aaron 242: option is also specified, show routing statistics instead.
1.26 brian 243: .It Fl s
244: Show per-protocol statistics.
245: If this option is repeated, counters with a value of zero are suppressed.
1.31 jmc 246: .It Fl t
247: With the
248: .Fl i
249: option, display the current value of the watchdog timer function.
250: .It Fl u
251: Limit statistics or address control block reports to the
252: .Dv AF_UNIX
253: address family.
1.10 peter 254: .It Fl v
1.19 itojun 255: Be verbose.
256: Avoids truncation of long addresses.
1.42 reyk 257: .It Fl W Ar interface
258: (IEEE 802.11 devices only)
259: Show per-interface IEEE 802.11 wireless statistics.
1.1 deraadt 260: .It Fl w Ar wait
261: Show network interface statistics at intervals of
262: .Ar wait
263: seconds.
264: .El
265: .Pp
266: The default display, for active sockets, shows the local
267: and remote addresses, send and receive queue sizes (in bytes), protocol,
268: and the internal state of the protocol.
1.21 aaron 269: .Pp
270: Address formats are of the form
271: .Dq host.port
272: or
273: .Dq network.port
1.1 deraadt 274: if a socket's address specifies a network but no specific host address.
1.21 aaron 275: When known, the host and network addresses are displayed symbolically
276: according to the databases
1.1 deraadt 277: .Pa /etc/hosts
278: and
279: .Pa /etc/networks ,
1.21 aaron 280: respectively.
281: If a symbolic name for an address is unknown, or if the
1.1 deraadt 282: .Fl n
283: option is specified, the address is printed numerically, according
284: to the address family.
1.21 aaron 285: .Pp
286: For more information regarding the Internet
287: .Dq dot format ,
1.1 deraadt 288: refer to
1.12 aaron 289: .Xr inet 3 .
1.34 jmc 290: Unspecified or
1.21 aaron 291: .Dq wildcard
292: addresses and ports appear as a single
1.34 jmc 293: .Sq * .
1.6 deraadt 294: If a local port number is registered as being in use for RPC by
1.12 aaron 295: .Xr portmap 8 ,
1.11 aaron 296: its RPC service name or RPC service number will be printed in
1.21 aaron 297: .Dq []
298: immediately after the port number.
1.1 deraadt 299: .Pp
300: The interface display provides a table of cumulative
301: statistics regarding packets transferred, errors, and collisions.
302: The network addresses of the interface
1.21 aaron 303: and the maximum transmission unit (MTU) are also displayed.
1.1 deraadt 304: .Pp
1.21 aaron 305: The routing table display indicates the available routes and their status.
306: Each route consists of a destination host or network and
307: a gateway to use in forwarding packets.
308: If the destination is a
309: network in numeric format, the netmask (in /24 style format) is appended.
310: The flags field shows a collection of information about
311: the route stored as binary choices.
312: The individual flags are discussed in more detail in the
1.1 deraadt 313: .Xr route 8
314: and
315: .Xr route 4
316: manual pages.
1.21 aaron 317: .Pp
1.1 deraadt 318: The mapping between letters and flags is:
319: .Bl -column XXXX RTF_BLACKHOLE
1.12 aaron 320: 1 RTF_PROTO1 Protocol specific routing flag #1.
321: 2 RTF_PROTO2 Protocol specific routing flag #2.
1.25 niklas 322: 3 RTF_PROTO3 Protocol specific routing flag #3.
1.16 aaron 323: B RTF_BLACKHOLE Just discard pkts (during updates).
1.12 aaron 324: C RTF_CLONING Generate new routes on use.
1.34 jmc 325: c RTF_CLONED Cloned routes (generated from RTF_CLONING).
1.12 aaron 326: D RTF_DYNAMIC Created dynamically (by redirect).
327: G RTF_GATEWAY Destination requires forwarding by intermediary.
328: H RTF_HOST Host entry (net otherwise).
1.1 deraadt 329: L RTF_LLINFO Valid protocol to link address translation.
1.12 aaron 330: M RTF_MODIFIED Modified dynamically (by redirect).
331: R RTF_REJECT Host or net unreachable.
332: S RTF_STATIC Manually added.
333: U RTF_UP Route usable.
334: X RTF_XRESOLVE External daemon translates proto to link address.
1.1 deraadt 335: .El
336: .Pp
1.21 aaron 337: Direct routes are created for each interface attached to the local host;
1.1 deraadt 338: the gateway field for such entries shows the address of the outgoing interface.
1.21 aaron 339: The refcnt field gives the current number of active uses of the route.
340: Connection oriented protocols normally hold on to a single route for the
341: duration of a connection while connectionless protocols obtain a route while
342: sending to the same destination.
343: The use field provides a count of the number of packets sent using that route.
344: The MTU entry shows the MTU associated with that route.
345: This MTU value is used as the basis for the TCP maximum segment size (MSS).
1.34 jmc 346: The
347: .Sq L
348: flag appended to the MTU value indicates that the value is
349: locked, and that path MTU discovery is turned off for that route.
1.21 aaron 350: A
1.1 deraadt 351: .Sq -
1.12 aaron 352: indicates that the MTU for this route has not been set, and a default
1.21 aaron 353: TCP maximum segment size will be used.
354: The interface entry indicates the network interface utilized for the route.
1.1 deraadt 355: .Pp
356: When
1.21 aaron 357: .Nm
1.1 deraadt 358: is invoked with the
359: .Fl w
360: option and a
361: .Ar wait
362: interval argument, it displays a running count of statistics related to
363: network interfaces.
364: An obsolescent version of this option used a numeric parameter
365: with no option, and is currently supported for backward compatibility.
366: This display consists of a column for the primary interface (the first
367: interface found during autoconfiguration) and a column summarizing
368: information for all interfaces.
369: The primary interface may be replaced with another interface with the
370: .Fl I
371: option.
372: The first line of each screen of information contains a summary since the
1.21 aaron 373: system was last rebooted.
374: Subsequent lines of output show values accumulated over the preceding interval.
1.1 deraadt 375: .Sh SEE ALSO
376: .Xr nfsstat 1 ,
377: .Xr ps 1 ,
1.34 jmc 378: .Xr inet 3 ,
1.21 aaron 379: .Xr netintro 4 ,
1.34 jmc 380: .Xr route 4 ,
1.1 deraadt 381: .Xr hosts 5 ,
382: .Xr networks 5 ,
383: .Xr protocols 5 ,
384: .Xr services 5 ,
1.15 alex 385: .Xr iostat 8 ,
1.34 jmc 386: .Xr portmap 8 ,
387: .Xr route 8 ,
1.40 jmc 388: .Xr tcpdrop 8 ,
1.1 deraadt 389: .Xr trpt 8 ,
390: .Xr vmstat 8
391: .Sh HISTORY
392: The
1.21 aaron 393: .Nm
1.1 deraadt 394: command appeared in
395: .Bx 4.2 .
1.19 itojun 396: IPv6 support was added by WIDE/KAME project.
1.1 deraadt 397: .Sh BUGS
398: The notion of errors is ill-defined.