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