]>
Commit | Line | Data |
---|---|---|
b7080c8e A |
1 | .\" Copyright (c) 1983, 1990, 1992, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
32 | .\" @(#)netstat.1 8.8 (Berkeley) 4/18/94 | |
7ba0088d | 33 | .\" $FreeBSD: src/usr.bin/netstat/netstat.1,v 1.22.2.7 2001/08/10 09:07:09 ru Exp $ |
b7080c8e | 34 | .\" |
7ba0088d | 35 | .Dd June 15, 2001 |
b7080c8e | 36 | .Dt NETSTAT 1 |
7ba0088d | 37 | .Os Darwin |
b7080c8e A |
38 | .Sh NAME |
39 | .Nm netstat | |
40 | .Nd show network status | |
41 | .Sh SYNOPSIS | |
7ba0088d A |
42 | .Nm |
43 | .Op Fl AaLlnW | |
44 | .Op Fl f Ar address_family | Fl p Ar protocol | |
7ba0088d A |
45 | .Nm |
46 | .Op Fl gilns | |
fdfd5971 | 47 | .Op Fl v |
b7080c8e | 48 | .Op Fl f Ar address_family |
fdfd5971 | 49 | .Op Fl I Ar interface |
7ba0088d A |
50 | .Nm |
51 | .Fl i | I Ar interface | |
52 | .Op Fl w Ar wait | |
fdfd5971 | 53 | .Op Fl abdgRt |
7ba0088d A |
54 | .Nm |
55 | .Fl s Op Fl s | |
56 | .Op Fl f Ar address_family | Fl p Ar protocol | |
b8dff150 | 57 | .Op Fl w Ar wait |
7ba0088d A |
58 | .Nm |
59 | .Fl i | I Ar interface Fl s | |
60 | .Op Fl f Ar address_family | Fl p Ar protocol | |
7ba0088d A |
61 | .Nm |
62 | .Fl m | |
b8dff150 | 63 | .Op Fl m |
7ba0088d A |
64 | .Nm |
65 | .Fl r | |
66 | .Op Fl Aaln | |
67 | .Op Fl f Ar address_family | |
7ba0088d A |
68 | .Nm |
69 | .Fl rs | |
70 | .Op Fl s | |
7ba0088d | 71 | .\"----------------------------------------------------------------------------------------- |
b7080c8e | 72 | .Sh DESCRIPTION |
7ba0088d | 73 | .\"----------------------------------------------------------------------------------------- |
b7080c8e | 74 | The |
7ba0088d A |
75 | .Nm |
76 | command symbolically displays the contents of various network-related data structures. | |
77 | There are a number of output formats, depending on the options for the information presented. | |
78 | The first form of the command displays a list of active sockets for each protocol. | |
79 | The second form presents the contents of one of the other network data structures according | |
80 | to the option selected. Using the third form, with a | |
b7080c8e A |
81 | .Ar wait |
82 | interval specified, | |
7ba0088d A |
83 | .Nm |
84 | will continuously display the information regarding packet traffic on the configured network | |
b8dff150 A |
85 | interfaces. The fourth form displays statistics for the specified protocol or address family. If a |
86 | .Ar wait | |
87 | interval is specified, the protocol information over the last interval seconds will be displayed. | |
7ba0088d A |
88 | The fifth form displays per-interface statistics for the specified protocol or address family. |
89 | The sixth form displays | |
90 | .Xr mbuf 9 | |
91 | statistics. The seventh form displays routing table for the specified address family. The | |
92 | eighth form displays routing statistics. | |
b7080c8e A |
93 | .Pp |
94 | The options have the following meaning: | |
95 | .Bl -tag -width flag | |
96 | .It Fl A | |
7ba0088d A |
97 | With the default display, show the address of any protocol control blocks associated with |
98 | sockets; used for debugging. | |
b7080c8e | 99 | .It Fl a |
7ba0088d A |
100 | With the default display, show the state of all sockets; normally sockets used by server |
101 | processes are not shown. With the routing table display (option | |
102 | .Fl r , | |
103 | as described below), show protocol-cloned routes (routes generated by a | |
104 | .Dv RTF_PRCLONING | |
105 | parent route); normally these routes are not shown. | |
106 | .It Fl b | |
107 | With the interface display (option | |
108 | .Fl i , | |
109 | as described below), show the number of bytes in and out. | |
b7080c8e A |
110 | .It Fl d |
111 | With either interface display (option | |
112 | .Fl i | |
7ba0088d A |
113 | or an interval, as described below), show the number of dropped packets. |
114 | .It Fl f Ar address_family | |
115 | Limit statistics or address control block reports to those of the specified | |
b7080c8e | 116 | .Ar address family . |
7ba0088d | 117 | The following address families are recognized: |
b7080c8e A |
118 | .Ar inet , |
119 | for | |
120 | .Dv AF_INET , | |
7ba0088d | 121 | .Ar inet6 , |
b7080c8e | 122 | for |
7ba0088d | 123 | .Dv AF_INET6 |
b7080c8e A |
124 | and |
125 | .Ar unix , | |
126 | for | |
127 | .Dv AF_UNIX . | |
128 | .It Fl g | |
fdfd5971 | 129 | Show information related to multicast (group address) membership. If the |
b7080c8e | 130 | .Fl s |
fdfd5971 A |
131 | option is also present, show extended interface group management statistics. If the |
132 | .Fl v | |
133 | option is specified, show link-layer memberships; they are suppressed by default. | |
134 | Source lists for each group will also be printed. Specifiying | |
135 | .Fl v | |
136 | twice will print the control plane timers for each interface and the source list counters | |
137 | for each group. If the | |
138 | .Fl i | |
139 | is specified, only that interface will be shown. If the | |
140 | .Fl f | |
141 | is specified, only information for the address family will be displayed. | |
7ba0088d A |
142 | .It Fl I Ar interface |
143 | Show information about the specified interface; used with a | |
b7080c8e A |
144 | .Ar wait |
145 | interval as described below. | |
b7080c8e | 146 | If the |
7ba0088d A |
147 | .Fl s |
148 | option is present, show per-interface protocol statistics on the | |
149 | .Ar interface | |
150 | for the specified | |
151 | .Ar address_family | |
152 | or | |
153 | .Ar protocol , | |
154 | or for all protocol families. | |
155 | .It Fl i | |
156 | Show the state of interfaces which have been auto-configured (interfaces statically | |
157 | configured into a system, but not located at boot time are not shown). If the | |
b7080c8e | 158 | .Fl a |
7ba0088d A |
159 | options is also present, multicast addresses currently in use are shown for each |
160 | Ethernet interface and for each IP interface address. Multicast addresses are shown | |
161 | on separate lines following the interface address with which they are associated. | |
162 | If the | |
163 | .Fl s | |
164 | option is present, show per-interface statistics on all interfaces for the specified | |
165 | .Ar address_family | |
166 | or | |
167 | .Ar protocol , | |
168 | or for all protocol families. | |
169 | .It Fl L | |
170 | Show the size of the various listen queues. The first count shows the number of | |
171 | unaccepted connections. The second count shows the amount of unaccepted incomplete | |
172 | connections. The third count is the maximum number of queued connections. | |
173 | .It Fl l | |
174 | Print full IPv6 address. | |
b7080c8e | 175 | .It Fl m |
b8dff150 A |
176 | Show statistics recorded by the memory management routines (the network stack manages a private pool of memory buffers). More detailed information about the buffers, which includes their cache related statistics, can be obtained by using |
177 | .Fl mm | |
178 | or | |
179 | .Fl m | |
180 | .Fl m | |
181 | option. | |
b7080c8e A |
182 | .It Fl n |
183 | Show network addresses as numbers (normally | |
7ba0088d A |
184 | .Nm |
185 | interprets addresses and attempts to display them symbolically). This option may be | |
186 | used with any of the display formats. | |
187 | .It Fl p Ar protocol | |
b7080c8e | 188 | Show statistics about |
7ba0088d A |
189 | .Ar protocol , |
190 | which is either a well-known name for a protocol or an alias for it. Some protocol | |
191 | names and aliases are listed in the file | |
b7080c8e | 192 | .Pa /etc/protocols . |
7ba0088d A |
193 | The special protocol name |
194 | .Dq bdg | |
195 | is used to show bridging statistics. A null response typically means that there are | |
196 | no interesting numbers to report. The program will complain if | |
b7080c8e A |
197 | .Ar protocol |
198 | is unknown or if there is no statistics routine for it. | |
b7080c8e | 199 | .It Fl r |
7ba0088d A |
200 | Show the routing tables. Use with |
201 | .Fl a | |
202 | to show protocol-cloned routes. When | |
b7080c8e | 203 | .Fl s |
7ba0088d A |
204 | is also present, show routing statistics instead. When |
205 | .Fl l | |
206 | is also present, | |
207 | .Nm | |
208 | assumes more columns are there and the maximum transmission unit | |
209 | .Pq Dq mtu | |
210 | are also displayed. | |
fdfd5971 A |
211 | .It Fl R |
212 | Show reachability information. Use with | |
213 | .Fl i | |
214 | to show link-layer reachability information for a given interface. | |
7ba0088d A |
215 | .It Fl s |
216 | Show per-protocol statistics. If this option is repeated, counters with a value of | |
217 | zero are suppressed. | |
fdfd5971 A |
218 | .It Fl v |
219 | Increase verbosity level. | |
7ba0088d A |
220 | .It Fl W |
221 | In certain displays, avoid truncating addresses even if this causes some fields to | |
222 | overflow. | |
b7080c8e | 223 | .It Fl w Ar wait |
b8dff150 | 224 | Show network interface or protocol statistics at intervals of |
b7080c8e A |
225 | .Ar wait |
226 | seconds. | |
227 | .El | |
228 | .Pp | |
7ba0088d A |
229 | .\"------------------------------------------------------------------------------- |
230 | .Sh OUTPUT | |
231 | .\"------------------------------------------------------------------------------- | |
232 | The default display, for active sockets, shows the local and remote addresses, | |
233 | send and receive queue sizes (in bytes), protocol, and the internal state of | |
234 | the protocol. Address formats are of the form | |
235 | .Dq host.port | |
236 | or | |
237 | .Dq network.port | |
b7080c8e | 238 | if a socket's address specifies a network but no specific host address. |
7ba0088d A |
239 | If known, the host and network addresses are displayed symbolically |
240 | according to the databases | |
b7080c8e A |
241 | .Pa /etc/hosts |
242 | and | |
243 | .Pa /etc/networks , | |
7ba0088d | 244 | respectively. If a symbolic name for an address is unknown, or if the |
b7080c8e | 245 | .Fl n |
7ba0088d A |
246 | option is specified, the address is printed numerically, according to the |
247 | address family. For more information regarding the Internet | |
248 | .Dq dot format , | |
b7080c8e A |
249 | refer to |
250 | .Xr inet 3 ) . | |
251 | Unspecified, | |
7ba0088d A |
252 | or |
253 | .Dq wildcard , | |
254 | addresses and ports appear as | |
255 | .Dq * . | |
256 | .Pp | |
257 | Internet domain socket states: | |
258 | .Bl -column X LISTEN | |
259 | CLOSED: The socket is not in use. | |
260 | .Pp | |
261 | LISTEN: The socket is listening for incoming connections. Unconnected | |
262 | listening sockets like these are only displayed when using the -a option. | |
263 | .Pp | |
264 | SYN_SENT: The socket is actively trying to establish a connection to a | |
265 | remote peer. | |
b7080c8e | 266 | .Pp |
7ba0088d A |
267 | SYN_RCVD: The socket has passively received a connection request from a |
268 | remote peer. | |
b7080c8e | 269 | .Pp |
7ba0088d A |
270 | ESTABLISHED: The socket has an established connection between a local |
271 | application and a remote peer. | |
272 | .Pp | |
273 | CLOSE_WAIT: The socket connection has been closed by the remote peer, | |
274 | and the system is waiting for the local application to close its half of | |
275 | the connection. | |
276 | .Pp | |
277 | LAST_ACK: The socket connection has been closed by the remote peer, the | |
278 | local application has closed its half of the connection, and the system | |
279 | is waiting for the remote peer to acknowledge the close. | |
280 | .Pp | |
281 | FIN_WAIT_1: The socket connection has been closed by the local | |
282 | application, the remote peer has not yet acknowledged the close, and the | |
283 | system is waiting for it to close its half of the connection. | |
284 | .Pp | |
285 | FIN_WAIT_2: The socket connection has been closed by the local | |
286 | application, the remote peer has acknowledged the close, and the system | |
287 | is waiting for it to close its half of the connection. | |
288 | .Pp | |
289 | CLOSING: The socket connection has been closed by the local application | |
290 | and the remote peer simultaneously, and the remote peer has not yet | |
291 | acknowledged the close attempt of the local application. | |
292 | .Pp | |
293 | TIME_WAIT: The socket connection has been closed by the local | |
294 | application, the remote peer has closed its half of the connection, and | |
295 | the system is waiting to be sure that the remote peer received the last | |
296 | acknowledgement. | |
297 | .El | |
298 | .Pp | |
299 | The interface display provides a table of cumulative statistics regarding | |
300 | packets transferred, errors, and collisions. The network addresses of the | |
301 | interface and the maximum transmission unit | |
302 | .Pq Dq mtu | |
303 | are also displayed. | |
304 | .Pp | |
305 | The routing table display indicates the available routes and their status. | |
306 | Each route consists of a destination host or network and a gateway to use | |
307 | in forwarding packets. The flags field shows a collection of information | |
308 | about the route stored as binary choices. The individual flags are discussed | |
309 | in more detail in the | |
b7080c8e A |
310 | .Xr route 8 |
311 | and | |
312 | .Xr route 4 | |
7ba0088d | 313 | manual pages. The mapping between letters and flags is: |
b7080c8e | 314 | .Bl -column XXXX RTF_BLACKHOLE |
7ba0088d A |
315 | 1 RTF_PROTO1 Protocol specific routing flag #1 |
316 | 2 RTF_PROTO2 Protocol specific routing flag #2 | |
317 | 3 RTF_PROTO3 Protocol specific routing flag #3 | |
318 | B RTF_BLACKHOLE Just discard packets (during updates) | |
319 | b RTF_BROADCAST The route represents a broadcast address | |
320 | C RTF_CLONING Generate new routes on use | |
321 | c RTF_PRCLONING Protocol-specified generate new routes on use | |
322 | D RTF_DYNAMIC Created dynamically (by redirect) | |
b7080c8e | 323 | G RTF_GATEWAY Destination requires forwarding by intermediary |
7ba0088d | 324 | H RTF_HOST Host entry (net otherwise) |
9c859447 | 325 | I RTF_IFSCOPE Route is associated with an interface scope |
7f5b2e89 | 326 | i RTF_IFREF Route is holding a reference to the interface |
7ba0088d A |
327 | L RTF_LLINFO Valid protocol to link address translation |
328 | M RTF_MODIFIED Modified dynamically (by redirect) | |
9c859447 | 329 | m RTF_MULTICAST The route represents a multicast address |
7ba0088d A |
330 | R RTF_REJECT Host or net unreachable |
331 | S RTF_STATIC Manually added | |
332 | U RTF_UP Route usable | |
333 | W RTF_WASCLONED Route was generated as a result of cloning | |
b7080c8e A |
334 | X RTF_XRESOLVE External daemon translates proto to link address |
335 | .El | |
336 | .Pp | |
7ba0088d A |
337 | Direct routes are created for each interface attached to the local host; |
338 | the gateway field for such entries shows the address of the outgoing | |
339 | interface. The refcnt field gives the current number of active uses of | |
340 | the route. Connection oriented protocols normally hold on to a single | |
341 | route for the duration of a connection while connectionless protocols | |
342 | obtain a route while sending to the same destination. The use field | |
343 | provides a count of the number of packets sent using that route. The | |
344 | interface entry indicates the network interface utilized for the route. | |
9c859447 A |
345 | A route which is marked with the RTF_IFSCOPE flag is instantiated for |
346 | the corresponding interface. | |
b7080c8e A |
347 | .Pp |
348 | When | |
349 | .Nm netstat | |
350 | is invoked with the | |
351 | .Fl w | |
352 | option and a | |
353 | .Ar wait | |
354 | interval argument, it displays a running count of statistics related to | |
b8dff150 | 355 | network interfaces or protocols. An obsolete version of this option used a numeric |
7ba0088d A |
356 | parameter with no option, and is currently supported for backward |
357 | compatibility. By default, this display summarizes information for all | |
358 | interfaces. Information for a specific interface may be displayed with the | |
b7080c8e A |
359 | .Fl I |
360 | option. | |
b7080c8e | 361 | .Sh SEE ALSO |
7ba0088d | 362 | .Xr fstat 1 , |
b7080c8e A |
363 | .Xr nfsstat 1 , |
364 | .Xr ps 1 , | |
7ba0088d A |
365 | .Xr inet 4 , |
366 | .Xr unix 4 , | |
b7080c8e A |
367 | .Xr hosts 5 , |
368 | .Xr networks 5 , | |
369 | .Xr protocols 5 , | |
9c859447 | 370 | .Xr route 8 , |
b7080c8e | 371 | .Xr services 5 , |
7ba0088d | 372 | .Xr iostat 8 , |
b7080c8e | 373 | .Xr trpt 8 , |
7ba0088d | 374 | .Xr vmstat 8 |
b7080c8e A |
375 | .Sh HISTORY |
376 | The | |
377 | .Nm netstat | |
378 | command appeared in | |
379 | .Bx 4.2 . | |
7ba0088d A |
380 | .Pp |
381 | IPv6 support was added by WIDE/KAME project. | |
b7080c8e A |
382 | .Sh BUGS |
383 | The notion of errors is ill-defined. |