Debian Codegraph @

upstream/opensuse-tumbleweed/man8/netstat.8

raw
1 .\" netstat.8
2 .\" Original: ([email protected] & [email protected])
3 .\" Modified: [email protected]
4 .\" Modified: Andi Kleen [email protected]
5 .\" Modified: Tuan Hoang [email protected]
6 .\" Modified: Brian Micek [email protected]
7 .TH NETSTAT 8 "2025-09-10" "net\-tools" "Linux System Administrator's Manual"
8
9 .SH NAME
10 netstat \- print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
11
12 .SH SYNOPSIS
13 .SY netstat
14 .RI [ address_family_options ]
15 .RB [ \-\-tcp | \-t ]
16 .RB [ \-\-udp | \-u ]
17 .RB [ \-\-udplite | \-U ]
18 .RB [ \-\-sctp | \-S ]
19 .RB [ \-\-raw | \-w ]
20 .RB [ \-\-l2cap | \-2 ]
21 .RB [ \-\-rfcomm | \-f ]
22 .RB [ \-\-listening | \-l ]
23 .RB [ \-\-all | \-a ]
24 .RB [ \-\-numeric | \-n ]
25 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
26 .RB [ \-\-symbolic | \-N ]
27 .RB [ \-\-extend | \-e | \-ee ]
28 .RB [ \-\-timers | \-o ]
29 .RB [ \-\-program | \-p ]
30 .RB [ \-\-verbose | \-v ]
31 .RB [ \-\-continuous | \-c]
32 .RB [ \-\-wide | \-W ]
33 .P
34 .SY netstat
35 .RB { \-\-route | \-r }
36 .RI [ address_family_options ]
37 .RB [ \-\-extend | \-e | \-ee ]
38 .RB [ \-\-verbose | \-v ]
39 .RB [ \-\-numeric | \-n ]
40 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
41 .RB [ \-\-continuous | \-c ]
42 .P
43 .SY netstat
44 .RB { \-\-interfaces | \-i }
45 .RB [ \-\-all | \-a ]
46 .RB [ \-\-extend | \-e ]
47 .RB [ \-\-numeric | \-n ]
48 .RB [ \-\-numeric-hosts ]
49 .RB [ \-\-continuous | \-c ]
50 .P
51 .SY netstat
52 .RB { \-\-groups | \-g }
53 .RB [ \-\-numeric | \-n ]
54 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
55 .RB [ \-\-continuous | \-c ]
56 .P
57 .SY netstat
58 .RB { \-\-masquerade | \-M }
59 .RB [ \-\-extend | \-e ]
60 .RB [ \-\-numeric | \-n ]
61 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
62 .RB [ \-\-continuous | \-c ]
63 .P
64 .SY netstat
65 .RB { \-\-statistics | -s }
66 .RB [ \-\-tcp | \-t ]
67 .RB [ \-\-udp | \-u ]
68 .RB [ \-\-udplite | \-U ]
69 .RB [ \-\-sctp | \-S ]
70 .RB [ \-\-raw | \-w ]
71 .P
72 .SY netstat
73 .RB { \-\-version | \-V }
74 .br
75 .SY netstat
76 .RB { \-\-help | \-h }
77 .P
78 .IR address_family_options :
79 .br
80 .RB [ -4 | \-\-inet ]
81 .RB [ -6 | \-\-inet6 ]
82 .RB [ \-\-protocol= { inet , inet6 , unix , ipx ,\: ax25 , netrom , ddp , bluetooth ", ... } ]"
83 .RB [ \-\-unix | \-x ]
84 .RB [ \-\-inet | \-\-ip ]
85 .RB [ \-\-ax25 ]
86 .RB [ \-\-x25 ]
87 .RB [ \-\-rose ]
88 .RB [ \-\-ash ]
89 .RB [ \-\-bluetooth ]
90 .RB [ \-\-ipx ]
91 .RB [ \-\-netrom ]
92 .RB [ \-\-ddp | \-\-appletalk ]
93 .RB [ \-\-econet | \-\-ec ]
94 .ad
95 .hy \" turn back on
96
97 .SH NOTES
98 This program is mostly obsolete.
99 Replacement for \fBnetstat\fR is \fBss\fR.
100 Replacement for \fBnetstat -r\fR is \fBip route\fR.
101 Replacement for \fBnetstat -i\fR is \fBip -s link\fR.
102 Replacement for \fBnetstat -g\fR is \fBip maddr\fR.
103
104 .SH DESCRIPTION
105 .B Netstat
106 prints information about the Linux networking subsystem.
107
108 .SS Invocation Mode
109 The type of
110 information printed is controlled by the first argument, as follows:
111
112 .TP
113 (none)
114 By default,
115 .B netstat
116 displays a list of open sockets. If you don't specify any
117 address families, then the active sockets of all configured address
118 families will be printed.
119 .TP
120 .BR \-\-route ", " \-r
121 Display the kernel routing tables. See the description in
122 .BR route (8)
123 for details.
124 .B netstat -r
125 and
126 .B route -e
127 produce the same output.
128 .TP
129 .BR \-\-groups ", " \-g
130 Display multicast group membership information for IPv4 and IPv6.
131 .TP
132 .BR \-\-interfaces ", " \-i
133 Display a table of all network interfaces and their respective
134 reception and transmission errors counters. Without the \fB--extended\fP option
135 it produces same output as \fBifconfig -s\fP, otherwise the detailed list.
136 .TP
137 .BR \-\-masquerade ", " \-M
138 Display a list of masqueraded connections.
139 .TP
140 .BR \-\-statistics ", " \-s
141 Display summary (SNMP) statistics for each protocol.
142
143 .SH OPTIONS
144 .TP
145 .BR \-\-verbose ", " \-v
146 Tell the user what is going on by being verbose. Especially print some
147 useful information about unconfigured address families.
148 .TP
149 .BR \-\-wide ", " \-W
150 Do not truncate addresses by using output as wide as needed. This is
151 optional for now to not break existing scripts.
152 .TP
153 .BR \-\-numeric ", " \-n
154 Show numerical addresses instead of trying to determine symbolic host, port
155 or user names.
156 .TP
157 .B \-\-numeric\-hosts
158 shows numerical host addresses but does not affect the resolution of
159 port or user names.
160 .TP
161 .B \-\-numeric\-ports
162 shows numerical port numbers but does not affect the resolution of
163 host or user names.
164 .TP
165 .B \-\-numeric\-users
166 shows numerical user IDs but does not affect the resolution of host or
167 port names.
168 .TP
169 \fB\-\-protocol=\fIFamily\fR, \fB\-A\fP \fIFamily\fP
170 Specifies the address families (perhaps better described as low level
171 protocols) for which connections are to be shown.
172 .I Family
173 is a comma ('\fB,\fR') separated list of address family keywords like
174 .BR inet ,
175 .BR inet6 ,
176 .BR unix ,
177 .BR ipx ,
178 .BR ax25 ,
179 .BR netrom ,
180 .BR econet ,
181 .BR ddp ,
182 and
183 .BR bluetooth .
184 .br
185 This has the same effect as using the
186 .BR \-\-inet | -4 ,
187 .BR \-\-inet6 | -6 ,
188 .BR \-\-unix | -x ,
189 .BR \-\-ipx ,
190 .BR \-\-ax25 ,
191 .BR \-\-netrom ,
192 .BR \-\-ddp ,
193 and
194 .B \-\-bluetooth
195 options.
196
197 The address family
198 .B inet
199 (IPv4) includes raw, udp, udplite and tcp protocol sockets.
200
201 The address family
202 .B bluetooth
203 includes l2cap and rfcomm protocol sockets.
204 .TP
205 .BR \-c ", " \-\-continuous
206 This will cause
207 .B netstat
208 to print the selected information every second continuously.
209 .TP
210 .BR \-e ", " \-\-extend
211 Display additional information. Use this option twice for maximum detail.
212 .TP
213 .BR \-o ", " \-\-timers
214 Include information related to networking timers.
215 .TP
216 .BR \-p ", " \-\-program
217 Show the PID and name of the program to which each socket belongs.
218 A hyphen is shown if the socket belongs to the kernel (e.g. a kernel service,
219 or the process has exited but the socket hasn't finished closing yet).
220 .TP
221 .BR \-l ", " \-\-listening
222 Show only listening sockets. (These are omitted by default.)
223 .TP
224 .BR \-a ", " \-\-all
225 Show both listening and non-listening sockets. With the
226 .B \-\-interfaces
227 option, show interfaces that are not up
228 .TP
229 .B \-F
230 Print routing information from the FIB. (This is the default.)
231 .TP
232 .B \-C
233 Print routing information from the route cache.
234 (The cache is no longer provided with Linux kernel 3.6).
235
236 .SH OUTPUT
237
238 .SS Active Internet connections \fR(TCP, UDP, UDPLite, raw)\fR
239 .TP
240 .B Proto
241 The protocol (tcp, udp, udpl, raw) used by the socket.
242 .TP
243 .B Recv\-Q
244 Established: The count of bytes not copied by the user program
245 connected to this socket.
246 .br
247 Listening: Since Kernel 2.6.18 this column contains the current accept queue.
248 .TP
249 .B Send\-Q
250 Established: The count of bytes not acknowledged by the remote host.
251 .br
252 Listening: Since Kernel 2.6.18 this column contains the maximum size
253 of the syn backlog.
254 .TP
255 .B Local Address
256 Address and port number of the local end of the socket. Unless the
257 .BR \-\-numeric " (" \-n )
258 option is specified, the socket address is resolved to its canonical
259 host name (FQDN), and the port number is translated into the
260 corresponding service name.
261 .TP
262 .B Foreign Address
263 Address and port number of the remote end of the socket.
264 Analogous to "Local Address".
265 .TP
266 .B State
267 The state of the socket. Since there are no states in raw mode and usually no
268 states used in UDP and UDPLite, this column may be left blank.
269 Normally this can be one of several values:
270 .RS
271 .TP
272 .I ESTABLISHED
273 The socket has an established connection.
274 .TP
275 .I SYN_SENT
276 The socket is actively attempting to establish a connection.
277 .TP
278 .I SYN_RECV
279 A connection request has been received from the network.
280 .TP
281 .I FIN_WAIT1
282 The socket is closed, and the connection is shutting down.
283 .TP
284 .I FIN_WAIT2
285 Connection is closed, and the socket is waiting for a shutdown from the
286 remote end.
287 .TP
288 .I TIME_WAIT
289 The socket is waiting after close to handle packets still in the network.
290 .TP
291 .I CLOSE
292 The socket is not being used.
293 .TP
294 .I CLOSE_WAIT
295 The remote end has shut down, waiting for the socket to close.
296 .TP
297 .I LAST_ACK
298 The remote end has shut down, and the socket is closed. Waiting for
299 acknowledgement.
300 .TP
301 .I LISTEN
302 The socket is listening for incoming connections. Such sockets are
303 not included in the output unless you specify the
304 .BR \-\-listening " (" \-l )
305 or
306 .BR \-\-all " (" \-a )
307 option.
308 .TP
309 .I CLOSING
310 Both sockets are shut down but we still don't have all our data
311 sent.
312 .TP
313 .I UNKNOWN
314 The state of the socket is unknown.
315 .RE
316
317 .TP
318 .B "User"
319 The username or the user id (UID) of the owner of the socket.
320 .TP
321 .B "PID/Program name"
322 Slash-separated pair of the process id (PID) and process name of the
323 process that owns the socket.
324 .B \-\-program
325 causes this column to be included. You will also need
326 .I superuser
327 privileges to see this information on sockets you don't own. This
328 identification information is not yet available for IPX sockets.
329 .TP
330 .B "Timer"
331 TCP timer associated with this socket. The format is timer(a/b/c).
332 The timer is one of the following values:
333
334 .RS
335 .TP
336 .I off
337 There is no timer set for this socket.
338 .TP
339 .I on
340 The retransmission timer is active for the socket.
341 .TP
342 .I keepalive
343 The keepalive timer is active for the socket.
344 .TP
345 .I timewait
346 The connection is closing and the timewait timer is active for the socket.
347
348 The values in the brackets:
349
350 .RS
351 .TP
352 .I a
353 Timer value.
354 .TP
355 .I b
356 Number of retransmissions sent.
357 .TP
358 .I c
359 Number of keepalives sent.
360 .RE
361 .RE
362
363 .SS Active UNIX domain Sockets
364 .TP
365 .B "Proto"
366 The protocol (usually unix) used by the socket.
367 .TP
368 .B "RefCnt"
369 The reference count (i.e. attached processes via this socket).
370 .TP
371 .B "Flags"
372 The flags displayed is SO_ACCEPTON (displayed as
373 .BR ACC ),
374 SO_WAITDATA
375 .RB ( W )
376 or SO_NOSPACE
377 .RB ( N ).
378 SO_ACCECPTON
379 is used on unconnected sockets if their corresponding
380 processes are waiting for a connect request. The other flags are not
381 of normal interest.
382 .TP
383 .B "Type"
384 There are several types of socket access:
385
386 .RS
387 .TP
388 .I SOCK_DGRAM
389 The socket is used in Datagram (connectionless) mode.
390 .TP
391 .I SOCK_STREAM
392 This is a stream (connection) socket.
393 .TP
394 .I SOCK_RAW
395 The socket is used as a raw socket.
396 .TP
397 .I SOCK_RDM
398 This one serves reliably-delivered messages.
399 .TP
400 .I SOCK_SEQPACKET
401 This is a sequential packet socket.
402 .TP
403 .I SOCK_PACKET
404 Raw interface access socket.
405 .TP
406 .I UNKNOWN
407 Who ever knows what the future will bring us - just fill in here :-)
408 .RE
409
410 .TP
411 .B "State"
412 This field will contain one of the following Keywords:
413
414 .RS
415 .TP
416 .I FREE
417 The socket is not allocated
418 .TP
419 .I LISTENING
420 The socket is listening for a connection request. Such
421 sockets are only included in the output if you specify the
422 .BR \-\-listening " (" \-l )
423 or
424 .BR \-\-all " (" \-a )
425 option.
426 .TP
427 .I CONNECTING
428 The socket is about to establish a connection.
429 .TP
430 .I CONNECTED
431 The socket is connected.
432 .TP
433 .I DISCONNECTING
434 The socket is disconnecting.
435 .TP
436 .I (empty)
437 The socket is not connected to another one.
438 .TP
439 .I UNKNOWN
440 This state should never happen.
441 .RE
442
443 .TP
444 .B "PID/Program name"
445 Process ID (PID) and process name of the process that has the socket open.
446 More info available in
447 .B "Active Internet connections"
448 section written above.
449 .TP
450 .B "Path"
451 This is the path name as which the corresponding processes attached
452 to the socket.
453
454 .SS Active IPX sockets
455 (this needs to be done by somebody who knows it)
456
457 .SS Active NET/ROM sockets
458 (this needs to be done by somebody who knows it)
459
460 .SS Active AX.25 sockets
461 (this needs to be done by somebody who knows it)
462
463 .SS Kernel Interface table (-i)
464 Output format depends on the \fB\-\-extended\fP flag.
465 if not specified the output is compatible to the short \fBifconfig \-s\fP
466 statistics table, otherwise the detailed interface list is used.
467 Both documented in
468 .BR ifconfig (8).
469
470 .SS Kernel IP routing table (-r)
471 Output format depends on the \fB\-\-extended\fP flags.
472 If not specified the output is the same as \fBroute \-e\fP.
473 If one is specified, the output is the same as \fBroute\fP default format.
474 If the extended option is specified twice,
475 the output is same as \fBroute \-ee\fP.
476 All three documented in
477 .BR route (8).
478
479 .SH FILES
480 .ta
481 .I /etc/services
482 -- The services translation file
483
484 .I /proc
485 -- Mount point for the proc filesystem,
486 which gives access to kernel status information via the following files.
487
488 .I /proc/net/dev
489 -- device information
490
491 .I /proc/net/raw
492 -- raw socket information
493
494 .I /proc/net/tcp
495 -- TCP socket information
496
497 .I /proc/net/udp
498 -- UDP socket information
499
500 .I /proc/net/udplite
501 -- UDPLite socket information
502
503 .I /proc/net/igmp
504 -- IGMP multicast information
505
506 .I /proc/net/unix
507 -- Unix domain socket information
508
509 .I /proc/net/ipx
510 -- IPX socket information
511
512 .I /proc/net/ax25
513 -- AX25 socket information
514
515 .I /proc/net/appletalk
516 -- DDP (appletalk) socket information
517
518 .I /proc/net/nr
519 -- NET/ROM socket information
520
521 .I /proc/net/route
522 -- IP routing information
523
524 .I /proc/net/ax25_route
525 -- AX25 routing information
526
527 .I /proc/net/ipx_route
528 -- IPX routing information
529
530 .I /proc/net/nr_nodes
531 -- NET/ROM nodelist
532
533 .I /proc/net/nr_neigh
534 -- NET/ROM neighbours
535
536 .I /proc/net/ip_masquerade
537 -- masqueraded connections
538
539 .I /sys/kernel/debug/bluetooth/l2cap
540 -- Bluetooth L2CAP information
541
542 .I /sys/kernel/debug/bluetooth/rfcomm
543 -- Bluetooth serial connections
544
545 .I /proc/net/snmp
546 -- statistics
547
548 .SH BUGS
549 Occasionally strange information may appear if a socket changes
550 as it is viewed. This is unlikely to occur.
551
552 The performance when listing large number of sockets on busy servers
553 is low, use the
554 .BR netlink (7)
555 based
556 .BR ss (8)
557 command instead.
558
559 .SH SEE ALSO
560 Homepage of the \fInet\-tools\fP project:
561 .UR https://net-tools.sourceforge.io
562 .UE
563
564 .P
565 .BR route (8),
566 .BR ifconfig (8),
567 .BR iptables (8),
568 .BR ss (8),
569 .BR ip (8)
570 .br
571 .BR proc (5)
572
573 .SH AUTHORS
574 The netstat user interface was written by Fred Baumgarten
575 <[email protected]\-karlsruhe.de>,
576 the man page by Matt Welsh <[email protected]>.
577 It was updated by
578 Alan Cox <[email protected]>,
579 Tuan Hoang <[email protected]>, and
580 Bernd Eckenfels <net\[email protected]>.
581 UDPLite options were added by Brian Micek <[email protected]>.