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