158278509SDag-Erling Smørgrav.\"- 2e738085bSDag-Erling Smørgrav.\" Copyright (c) 1999 Dag-Erling Smørgrav 358278509SDag-Erling Smørgrav.\" All rights reserved. 458278509SDag-Erling Smørgrav.\" 558278509SDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without 658278509SDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions 758278509SDag-Erling Smørgrav.\" are met: 858278509SDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright 958278509SDag-Erling Smørgrav.\" notice, this list of conditions and the following disclaimer 1058278509SDag-Erling Smørgrav.\" in this position and unchanged. 1158278509SDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright 1258278509SDag-Erling Smørgrav.\" notice, this list of conditions and the following disclaimer in the 1358278509SDag-Erling Smørgrav.\" documentation and/or other materials provided with the distribution. 1458278509SDag-Erling Smørgrav.\" 3. The name of the author may not be used to endorse or promote products 1558278509SDag-Erling Smørgrav.\" derived from this software without specific prior written permission. 1658278509SDag-Erling Smørgrav.\" 1758278509SDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1858278509SDag-Erling Smørgrav.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1958278509SDag-Erling Smørgrav.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2058278509SDag-Erling Smørgrav.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2158278509SDag-Erling Smørgrav.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2258278509SDag-Erling Smørgrav.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2358278509SDag-Erling Smørgrav.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2458278509SDag-Erling Smørgrav.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2558278509SDag-Erling Smørgrav.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2658278509SDag-Erling Smørgrav.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2758278509SDag-Erling Smørgrav.\" 28*9f55128fSGleb Smirnoff.Dd February 6, 2025 295ff829fdSSheldon Hearn.Dt SOCKSTAT 1 3062500372SRuslan Ermilov.Os 3158278509SDag-Erling Smørgrav.Sh NAME 3258278509SDag-Erling Smørgrav.Nm sockstat 33ac1070c6SDag-Erling Smørgrav.Nd list open sockets 3458278509SDag-Erling Smørgrav.Sh SYNOPSIS 3558278509SDag-Erling Smørgrav.Nm 36*9f55128fSGleb Smirnoff.Op Fl 46ACcfIiLlnqSsUuvw 375504d839SFelix Johnson.Op Fl j Ar jail 3803f28475SDag-Erling Smørgrav.Op Fl p Ar ports 391f3d67aaSGiorgos Keramidas.Op Fl P Ar protocols 4058278509SDag-Erling Smørgrav.Sh DESCRIPTION 4158278509SDag-Erling SmørgravThe 4258278509SDag-Erling Smørgrav.Nm 433ce0d6e8SRuslan Ermilovcommand lists open Internet or 443ce0d6e8SRuslan Ermilov.Ux 453ce0d6e8SRuslan Ermilovdomain sockets. 46ac1070c6SDag-Erling Smørgrav.Pp 47ac1070c6SDag-Erling SmørgravThe following options are available: 48ac1070c6SDag-Erling Smørgrav.Bl -tag -width Fl 49ac1070c6SDag-Erling Smørgrav.It Fl 4 503ce0d6e8SRuslan ErmilovShow 513ce0d6e8SRuslan Ermilov.Dv AF_INET 523ce0d6e8SRuslan Ermilov(IPv4) sockets. 53ac1070c6SDag-Erling Smørgrav.It Fl 6 543ce0d6e8SRuslan ErmilovShow 553ce0d6e8SRuslan Ermilov.Dv AF_INET6 563ce0d6e8SRuslan Ermilov(IPv6) sockets. 57*9f55128fSGleb Smirnoff.It Fl A 58*9f55128fSGleb SmirnoffShow the address of a protocol control block (PCB) associated with a socket; 59*9f55128fSGleb Smirnoffused for debugging. 602ac089d0SMichael Tuexen.It Fl C 612ac089d0SMichael TuexenDisplay the congestion control module, if applicable. 622ac089d0SMichael TuexenThis is currently only implemented for TCP. 63a0581bbcSDag-Erling Smørgrav.It Fl c 64a0581bbcSDag-Erling SmørgravShow connected sockets. 65a471d2b4SMark Johnston.It Fl f 66a471d2b4SMark JohnstonShow the FIB number of each socket. 67051a2132SMark Johnston.It Fl I 68051a2132SMark JohnstonShow the local address of the socket to which the current socket is spliced, if 69051a2132SMark Johnstonany. 70051a2132SMark JohnstonSee the 71051a2132SMark Johnston.Xr setsockopt 2 72051a2132SMark Johnston.Dv SO_SPLICE 73051a2132SMark Johnstonoption for more information. 745f64777aSMichael Tuexen.It Fl i 755f64777aSMichael TuexenDisplay the 765f64777aSMichael Tuexen.Dv inp_gencnt . 77de68a320SJamie Gritton.It Fl j Ar jail 78de68a320SJamie GrittonShow only sockets belonging to the specified jail ID or name. 799b6ca892SBruce M Simpson.It Fl L 80f03482d4SMichael TuexenOnly show Internet sockets if the local and foreign addresses are not 819b6ca892SBruce M Simpsonin the loopback network prefix 829b6ca892SBruce M Simpson.Li 127.0.0.0/8 , 839b6ca892SBruce M Simpsonor do not contain the IPv6 loopback address 849b6ca892SBruce M Simpson.Li ::1 . 85a0581bbcSDag-Erling Smørgrav.It Fl l 86a0581bbcSDag-Erling SmørgravShow listening sockets. 87ccdd2b2bSAlexander Motin.It Fl n 88ccdd2b2bSAlexander MotinDo not resolve numeric UIDs to user names. 8903f28475SDag-Erling Smørgrav.It Fl p Ar ports 9025044bbcSMichael TuexenOnly show Internet sockets if the local or foreign port number 9103f28475SDag-Erling Smørgravis on the specified list. 9203f28475SDag-Erling SmørgravThe 9303f28475SDag-Erling Smørgrav.Ar ports 9403f28475SDag-Erling Smørgravargument is a comma-separated list of port numbers and ranges 9503f28475SDag-Erling Smørgravspecified as first and last port separated by a dash. 961f3d67aaSGiorgos Keramidas.It Fl P Ar protocols 971f3d67aaSGiorgos KeramidasOnly show sockets of the specified 981f3d67aaSGiorgos Keramidas.Ar protocols . 991f3d67aaSGiorgos KeramidasThe 1001f3d67aaSGiorgos Keramidas.Ar protocols 1011f3d67aaSGiorgos Keramidasargument is a comma-separated list of protocol names, 1021f3d67aaSGiorgos Keramidasas they are defined in 1031f3d67aaSGiorgos Keramidas.Xr protocols 5 . 104ee0afaa9SEmmanuel Vadot.It Fl q 105ee0afaa9SEmmanuel VadotQuiet mode, do not print the header line. 106e5cccc35SMichael Tuexen.It Fl S 107e5cccc35SMichael TuexenDisplay the protocol stack, if applicable. 108e5cccc35SMichael TuexenThis is currently only implemented for TCP. 1097a5642b3SDag-Erling Smørgrav.It Fl s 1107a5642b3SDag-Erling SmørgravDisplay the protocol state, if applicable. 1116414db1bSMichael TuexenThis is currently only implemented for SCTP and TCP. 11249b836f2SMichael Tuexen.It Fl U 11349b836f2SMichael TuexenDisplay the remote UDP encapsulation port number, if applicable. 1149e644c23SMichael TuexenThis is currently only implemented for SCTP and TCP. 115ac1070c6SDag-Erling Smørgrav.It Fl u 1163ce0d6e8SRuslan ErmilovShow 1173ce0d6e8SRuslan Ermilov.Dv AF_LOCAL 1183ce0d6e8SRuslan Ermilov.Pq Ux 1193ce0d6e8SRuslan Ermilovsockets. 12083f60cb2SMichael Tuexen.It Fl v 12183f60cb2SMichael TuexenVerbose mode. 12283f60cb2SMichael Tuexen.It Fl w 12383f60cb2SMichael TuexenUse wider field size for displaying addresses. 124ac1070c6SDag-Erling Smørgrav.El 125ac1070c6SDag-Erling Smørgrav.Pp 126a0581bbcSDag-Erling SmørgravIf neither 1273ce0d6e8SRuslan Ermilov.Fl 4 , 6 128a0581bbcSDag-Erling Smørgravor 129a0581bbcSDag-Erling Smørgrav.Fl u 130a0581bbcSDag-Erling Smørgravis specified, 131ac1070c6SDag-Erling Smørgrav.Nm 132a0581bbcSDag-Erling Smørgravwill list sockets in all three domains. 133a0581bbcSDag-Erling Smørgrav.Pp 134a0581bbcSDag-Erling SmørgravIf neither 135a0581bbcSDag-Erling Smørgrav.Fl c 136a0581bbcSDag-Erling Smørgravor 137a0581bbcSDag-Erling Smørgrav.Fl l 138a0581bbcSDag-Erling Smørgravis specified, 139a0581bbcSDag-Erling Smørgrav.Nm 140a0581bbcSDag-Erling Smørgravwill list both listening and connected sockets. 141ac1070c6SDag-Erling Smørgrav.Pp 14287faa07bSSheldon HearnThe information listed for each 14358278509SDag-Erling Smørgravsocket is: 14414802b60SDag-Erling Smørgrav.Bl -tag -width "FOREIGN ADDRESS" 14558278509SDag-Erling Smørgrav.It Li USER 14658278509SDag-Erling SmørgravThe user who owns the socket. 14758278509SDag-Erling Smørgrav.It Li COMMAND 14858278509SDag-Erling SmørgravThe command which holds the socket. 14958278509SDag-Erling Smørgrav.It Li PID 15058278509SDag-Erling SmørgravThe process ID of the command which holds the socket. 15158278509SDag-Erling Smørgrav.It Li FD 15258278509SDag-Erling SmørgravThe file descriptor number of the socket. 15358278509SDag-Erling Smørgrav.It Li PROTO 154ac1070c6SDag-Erling SmørgravThe transport protocol associated with the socket for Internet 155b8e20e2dSHiroki Satosockets, or the type of socket 156b8e20e2dSHiroki Sato.Pq stream, datagram, or seqpacket 157b8e20e2dSHiroki Satofor 1583ce0d6e8SRuslan Ermilov.Ux 1593ce0d6e8SRuslan Ermilovsockets. 16058278509SDag-Erling Smørgrav.It Li LOCAL ADDRESS 161ca007d91SDag-Erling SmørgravFor Internet sockets, this is the address the local end of the socket 162ca007d91SDag-Erling Smørgravis bound to (see 16358278509SDag-Erling Smørgrav.Xr getsockname 2 ) . 1642c436d48SGleb Smirnoff.Pp 165ca007d91SDag-Erling SmørgravFor bound 166ca007d91SDag-Erling Smørgrav.Ux 1672c436d48SGleb Smirnoffsockets, socket's filename is printed. 1682c436d48SGleb SmirnoffFor not bound 169ca007d91SDag-Erling Smørgrav.Ux 1702c436d48SGleb Smirnoffsockets, the field is empty. 17158278509SDag-Erling Smørgrav.It Li FOREIGN ADDRESS 1722c436d48SGleb SmirnoffFor Internet sockets, this is the address the foreign end of the socket 1732c436d48SGleb Smirnoffis bound to (see 17458278509SDag-Erling Smørgrav.Xr getpeername 2 ) . 1752c436d48SGleb Smirnoff.Pp 1762c436d48SGleb SmirnoffFor bound 1772c436d48SGleb Smirnoff.Ux 1782c436d48SGleb Smirnoffsockets a left arrow followed by the peer list is printed. 1792c436d48SGleb SmirnoffFor 1802c436d48SGleb Smirnoff.Ux 1812c436d48SGleb Smirnoffsockets that went through 1822c436d48SGleb Smirnoff.Xr connect 2 1832c436d48SGleb Smirnoffsystem call a right arrow followed by the peer is printed. 1842c436d48SGleb SmirnoffPeers are printed in square brackets as [PID FD]. 1855f64777aSMichael Tuexen.It Li ID 1865f64777aSMichael TuexenThe inp_gencnt if 1875f64777aSMichael Tuexen.Fl i 1885f64777aSMichael Tuexenis specified (only for TCP or UDP). 18949b836f2SMichael Tuexen.It Li ENCAPS 19049b836f2SMichael TuexenThe remote UDP encapsulation port number if 19149b836f2SMichael Tuexen.Fl U 1929e644c23SMichael Tuexenis specified (only for SCTP or TCP). 193e389705eSMichael Tuexen.It Li PATH STATE 194e389705eSMichael TuexenThe path state if 195e389705eSMichael Tuexen.Fl s 196e389705eSMichael Tuexenis specified (only for SCTP). 197e389705eSMichael Tuexen.It Li CONN STATE 198e389705eSMichael TuexenThe connection state if 199e5cccc35SMichael Tuexen.Fl s 200e5cccc35SMichael Tuexenis specified (only for SCTP or TCP). 201e5cccc35SMichael Tuexen.It Li STACK 202e5cccc35SMichael TuexenThe protocol stack if 203e5cccc35SMichael Tuexen.Fl S 204e5cccc35SMichael Tuexenis specified (only for TCP). 2052ac089d0SMichael Tuexen.It Li CC 2062ac089d0SMichael TuexenThe congestion control if 2072ac089d0SMichael Tuexen.Fl C 2082ac089d0SMichael Tuexenis specified (only for TCP). 20958278509SDag-Erling Smørgrav.El 21097c6143cSPeter Pentchev.Pp 21161149f8dSJilles TjoelkerIf a socket is associated with more than one file descriptor, 21261149f8dSJilles Tjoelkerit is shown multiple times. 21361149f8dSJilles TjoelkerIf a socket is not associated with any file descriptor, 21461149f8dSJilles Tjoelkerthe first four columns have no meaning. 215f893fe7aSFernando Apesteguía.Sh EXAMPLES 216f893fe7aSFernando ApesteguíaShow information for IPv4 sockets listening on port 22 using protocol 217f893fe7aSFernando ApesteguíaTCP: 218f893fe7aSFernando Apesteguía.Bd -literal -offset indent 219f893fe7aSFernando Apesteguía$ sockstat -4 -l -P tcp -p 22 220f893fe7aSFernando Apesteguía.Ed 221f893fe7aSFernando Apesteguía.Pp 222f893fe7aSFernando ApesteguíaShow information for sockets using either TCP or UDP, if neither, the local nor 223f893fe7aSFernando Apesteguíathe foreign addresses are in the loopback network: 224f893fe7aSFernando Apesteguía.Bd -literal -offset indent 225f893fe7aSFernando Apesteguía$ sockstat -L -P tcp,udp 226f893fe7aSFernando Apesteguía.Ed 227f893fe7aSFernando Apesteguía.Pp 228f893fe7aSFernando ApesteguíaShow TCP IPv6 sockets which are listening and connected (default): 229f893fe7aSFernando Apesteguía.Bd -literal -offset indent 230f893fe7aSFernando Apesteguía$ sockstat -6 -P tcp 231f893fe7aSFernando Apesteguía.Ed 23258278509SDag-Erling Smørgrav.Sh SEE ALSO 23358278509SDag-Erling Smørgrav.Xr fstat 1 , 23414802b60SDag-Erling Smørgrav.Xr netstat 1 , 235e5002279SEdward Tomasz Napierala.Xr procstat 1 , 236a471d2b4SMark Johnston.Xr setfib 1 , 237482ca427SYoshinobu Inoue.Xr inet 4 , 2381f3d67aaSGiorgos Keramidas.Xr inet6 4 , 2391f3d67aaSGiorgos Keramidas.Xr protocols 5 24058278509SDag-Erling Smørgrav.Sh HISTORY 24158278509SDag-Erling SmørgravThe 24258278509SDag-Erling Smørgrav.Nm 24358278509SDag-Erling Smørgravcommand appeared in 24458278509SDag-Erling Smørgrav.Fx 3.1 . 24558278509SDag-Erling Smørgrav.Sh AUTHORS 24658278509SDag-Erling SmørgravThe 24758278509SDag-Erling Smørgrav.Nm 24858278509SDag-Erling Smørgravcommand and this manual page were written by 2492b7af31cSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . 250