Annotation of src/usr.bin/netstat/netstat.1, Revision 1.24
1.24 ! camield 1: .\" $OpenBSD: netstat.1,v 1.23 2000/12/11 17:33:07 provos 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.24 ! camield 50: .Op Fl bdgimnrs
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
185: instead of the default
186: .Pa /dev/kmem .
187: .It Fl m
188: Show statistics recorded by the memory management routines
189: (the network manages a private pool of memory buffers).
1.17 deraadt 190: .It Fl N Ar system
1.1 deraadt 191: Extract the name list from the specified system instead of the default
1.3 ccappuc 192: .Pa /bsd .
1.1 deraadt 193: .It Fl n
194: Show network addresses as numbers (normally
1.21 aaron 195: .Nm
1.1 deraadt 196: interprets addresses and attempts to display them
197: symbolically).
198: This option may be used with any of the display formats.
1.16 aaron 199: .It Fl p Ar protocol
1.1 deraadt 200: Show statistics about
1.12 aaron 201: .Ar protocol ,
1.21 aaron 202: which is either a well-known name for a protocol or an alias for it.
203: Some protocol names and aliases are listed in the file
1.1 deraadt 204: .Pa /etc/protocols .
205: A null response typically means that there are no interesting numbers to
206: report.
207: The program will complain if
208: .Ar protocol
209: is unknown or if there is no statistics routine for it.
210: .It Fl s
211: Show per-protocol statistics.
212: If this option is repeated, counters with a value of zero are suppressed.
213: .It Fl r
214: Show the routing tables.
1.21 aaron 215: If the
1.1 deraadt 216: .Fl s
1.21 aaron 217: option is also specified, show routing statistics instead.
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.16 aaron 283: B RTF_BLACKHOLE Just discard pkts (during updates).
1.12 aaron 284: C RTF_CLONING Generate new routes on use.
285: D RTF_DYNAMIC Created dynamically (by redirect).
286: G RTF_GATEWAY Destination requires forwarding by intermediary.
287: H RTF_HOST Host entry (net otherwise).
1.1 deraadt 288: L RTF_LLINFO Valid protocol to link address translation.
1.12 aaron 289: M RTF_MODIFIED Modified dynamically (by redirect).
290: R RTF_REJECT Host or net unreachable.
291: S RTF_STATIC Manually added.
292: U RTF_UP Route usable.
293: X RTF_XRESOLVE External daemon translates proto to link address.
1.1 deraadt 294: .El
295: .Pp
1.21 aaron 296: Direct routes are created for each interface attached to the local host;
1.1 deraadt 297: the gateway field for such entries shows the address of the outgoing interface.
1.21 aaron 298: The refcnt field gives the current number of active uses of the route.
299: Connection oriented protocols normally hold on to a single route for the
300: duration of a connection while connectionless protocols obtain a route while
301: sending to the same destination.
302: The use field provides a count of the number of packets sent using that route.
303: The MTU entry shows the MTU associated with that route.
304: This MTU value is used as the basis for the TCP maximum segment size (MSS).
1.23 provos 305: The 'L' flag appended to the mtu value indicates that the value is
306: locked, and that path mtu discovery is turned off for that route.
1.21 aaron 307: A
1.1 deraadt 308: .Sq -
1.12 aaron 309: indicates that the MTU for this route has not been set, and a default
1.21 aaron 310: TCP maximum segment size will be used.
311: The interface entry indicates the network interface utilized for the route.
1.1 deraadt 312: .Pp
313: When
1.21 aaron 314: .Nm
1.1 deraadt 315: is invoked with the
316: .Fl w
317: option and a
318: .Ar wait
319: interval argument, it displays a running count of statistics related to
320: network interfaces.
321: An obsolescent version of this option used a numeric parameter
322: with no option, and is currently supported for backward compatibility.
323: This display consists of a column for the primary interface (the first
324: interface found during autoconfiguration) and a column summarizing
325: information for all interfaces.
326: The primary interface may be replaced with another interface with the
327: .Fl I
328: option.
329: The first line of each screen of information contains a summary since the
1.21 aaron 330: system was last rebooted.
331: Subsequent lines of output show values accumulated over the preceding interval.
1.1 deraadt 332: .Sh SEE ALSO
333: .Xr nfsstat 1 ,
334: .Xr ps 1 ,
1.21 aaron 335: .Xr netintro 4 ,
1.1 deraadt 336: .Xr hosts 5 ,
337: .Xr networks 5 ,
338: .Xr protocols 5 ,
339: .Xr services 5 ,
1.15 alex 340: .Xr iostat 8 ,
1.1 deraadt 341: .Xr trpt 8 ,
342: .Xr trsp 8 ,
343: .Xr vmstat 8
344: .Sh HISTORY
345: The
1.21 aaron 346: .Nm
1.1 deraadt 347: command appeared in
348: .Bx 4.2 .
1.19 itojun 349: IPv6 support was added by WIDE/KAME project.
1.1 deraadt 350: .\" .Sh FILES
351: .\" .Bl -tag -width /dev/kmem -compact
1.3 ccappuc 352: .\" .It Pa /bsd
1.1 deraadt 353: .\" default kernel namelist
354: .\" .It Pa /dev/kmem
355: .\" default memory file
356: .\" .El
357: .Sh BUGS
358: The notion of errors is ill-defined.