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