158278509SDag-Erling Smørgrav.\"- 2fb2ad9d3SUlrich Spörlein.\" Copyright (c) 1999 Dag-Erling Coïdan 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.\" 28c3aac50fSPeter Wemm.\" $FreeBSD$ 2958278509SDag-Erling Smørgrav.\" 30*ccdd2b2bSAlexander Motin.Dd December 30, 2020 315ff829fdSSheldon Hearn.Dt SOCKSTAT 1 3262500372SRuslan Ermilov.Os 3358278509SDag-Erling Smørgrav.Sh NAME 3458278509SDag-Erling Smørgrav.Nm sockstat 35ac1070c6SDag-Erling Smørgrav.Nd list open sockets 3658278509SDag-Erling Smørgrav.Sh SYNOPSIS 3758278509SDag-Erling Smørgrav.Nm 38*ccdd2b2bSAlexander Motin.Op Fl 46CcLlnSsUuvw 3900feaafdSAndrew Thompson.Op Fl j Ar jid 4003f28475SDag-Erling Smørgrav.Op Fl p Ar ports 411f3d67aaSGiorgos Keramidas.Op Fl P Ar protocols 4258278509SDag-Erling Smørgrav.Sh DESCRIPTION 4358278509SDag-Erling SmørgravThe 4458278509SDag-Erling Smørgrav.Nm 453ce0d6e8SRuslan Ermilovcommand lists open Internet or 463ce0d6e8SRuslan Ermilov.Ux 473ce0d6e8SRuslan Ermilovdomain sockets. 48ac1070c6SDag-Erling Smørgrav.Pp 49ac1070c6SDag-Erling SmørgravThe following options are available: 50ac1070c6SDag-Erling Smørgrav.Bl -tag -width Fl 51ac1070c6SDag-Erling Smørgrav.It Fl 4 523ce0d6e8SRuslan ErmilovShow 533ce0d6e8SRuslan Ermilov.Dv AF_INET 543ce0d6e8SRuslan Ermilov(IPv4) sockets. 55ac1070c6SDag-Erling Smørgrav.It Fl 6 563ce0d6e8SRuslan ErmilovShow 573ce0d6e8SRuslan Ermilov.Dv AF_INET6 583ce0d6e8SRuslan Ermilov(IPv6) sockets. 592ac089d0SMichael Tuexen.It Fl C 602ac089d0SMichael TuexenDisplay the congestion control module, if applicable. 612ac089d0SMichael TuexenThis is currently only implemented for TCP. 62a0581bbcSDag-Erling Smørgrav.It Fl c 63a0581bbcSDag-Erling SmørgravShow connected sockets. 64de68a320SJamie Gritton.It Fl j Ar jail 65de68a320SJamie GrittonShow only sockets belonging to the specified jail ID or name. 669b6ca892SBruce M Simpson.It Fl L 67f03482d4SMichael TuexenOnly show Internet sockets if the local and foreign addresses are not 689b6ca892SBruce M Simpsonin the loopback network prefix 699b6ca892SBruce M Simpson.Li 127.0.0.0/8 , 709b6ca892SBruce M Simpsonor do not contain the IPv6 loopback address 719b6ca892SBruce M Simpson.Li ::1 . 72a0581bbcSDag-Erling Smørgrav.It Fl l 73a0581bbcSDag-Erling SmørgravShow listening sockets. 74*ccdd2b2bSAlexander Motin.It Fl n 75*ccdd2b2bSAlexander MotinDo not resolve numeric UIDs to user names. 7603f28475SDag-Erling Smørgrav.It Fl p Ar ports 7725044bbcSMichael TuexenOnly show Internet sockets if the local or foreign port number 7803f28475SDag-Erling Smørgravis on the specified list. 7903f28475SDag-Erling SmørgravThe 8003f28475SDag-Erling Smørgrav.Ar ports 8103f28475SDag-Erling Smørgravargument is a comma-separated list of port numbers and ranges 8203f28475SDag-Erling Smørgravspecified as first and last port separated by a dash. 831f3d67aaSGiorgos Keramidas.It Fl P Ar protocols 841f3d67aaSGiorgos KeramidasOnly show sockets of the specified 851f3d67aaSGiorgos Keramidas.Ar protocols . 861f3d67aaSGiorgos KeramidasThe 871f3d67aaSGiorgos Keramidas.Ar protocols 881f3d67aaSGiorgos Keramidasargument is a comma-separated list of protocol names, 891f3d67aaSGiorgos Keramidasas they are defined in 901f3d67aaSGiorgos Keramidas.Xr protocols 5 . 91ee0afaa9SEmmanuel Vadot.It Fl q 92ee0afaa9SEmmanuel VadotQuiet mode, do not print the header line. 93e5cccc35SMichael Tuexen.It Fl S 94e5cccc35SMichael TuexenDisplay the protocol stack, if applicable. 95e5cccc35SMichael TuexenThis is currently only implemented for TCP. 967a5642b3SDag-Erling Smørgrav.It Fl s 977a5642b3SDag-Erling SmørgravDisplay the protocol state, if applicable. 986414db1bSMichael TuexenThis is currently only implemented for SCTP and TCP. 9949b836f2SMichael Tuexen.It Fl U 10049b836f2SMichael TuexenDisplay the remote UDP encapsulation port number, if applicable. 10149b836f2SMichael TuexenThis is currently only implemented for SCTP. 102ac1070c6SDag-Erling Smørgrav.It Fl u 1033ce0d6e8SRuslan ErmilovShow 1043ce0d6e8SRuslan Ermilov.Dv AF_LOCAL 1053ce0d6e8SRuslan Ermilov.Pq Ux 1063ce0d6e8SRuslan Ermilovsockets. 10783f60cb2SMichael Tuexen.It Fl v 10883f60cb2SMichael TuexenVerbose mode. 10983f60cb2SMichael Tuexen.It Fl w 11083f60cb2SMichael TuexenUse wider field size for displaying addresses. 111ac1070c6SDag-Erling Smørgrav.El 112ac1070c6SDag-Erling Smørgrav.Pp 113a0581bbcSDag-Erling SmørgravIf neither 1143ce0d6e8SRuslan Ermilov.Fl 4 , 6 115a0581bbcSDag-Erling Smørgravor 116a0581bbcSDag-Erling Smørgrav.Fl u 117a0581bbcSDag-Erling Smørgravis specified, 118ac1070c6SDag-Erling Smørgrav.Nm 119a0581bbcSDag-Erling Smørgravwill list sockets in all three domains. 120a0581bbcSDag-Erling Smørgrav.Pp 121a0581bbcSDag-Erling SmørgravIf neither 122a0581bbcSDag-Erling Smørgrav.Fl c 123a0581bbcSDag-Erling Smørgravor 124a0581bbcSDag-Erling Smørgrav.Fl l 125a0581bbcSDag-Erling Smørgravis specified, 126a0581bbcSDag-Erling Smørgrav.Nm 127a0581bbcSDag-Erling Smørgravwill list both listening and connected sockets. 128ac1070c6SDag-Erling Smørgrav.Pp 12987faa07bSSheldon HearnThe information listed for each 13058278509SDag-Erling Smørgravsocket is: 13114802b60SDag-Erling Smørgrav.Bl -tag -width "FOREIGN ADDRESS" 13258278509SDag-Erling Smørgrav.It Li USER 13358278509SDag-Erling SmørgravThe user who owns the socket. 13458278509SDag-Erling Smørgrav.It Li COMMAND 13558278509SDag-Erling SmørgravThe command which holds the socket. 13658278509SDag-Erling Smørgrav.It Li PID 13758278509SDag-Erling SmørgravThe process ID of the command which holds the socket. 13858278509SDag-Erling Smørgrav.It Li FD 13958278509SDag-Erling SmørgravThe file descriptor number of the socket. 14058278509SDag-Erling Smørgrav.It Li PROTO 141ac1070c6SDag-Erling SmørgravThe transport protocol associated with the socket for Internet 142b8e20e2dSHiroki Satosockets, or the type of socket 143b8e20e2dSHiroki Sato.Pq stream, datagram, or seqpacket 144b8e20e2dSHiroki Satofor 1453ce0d6e8SRuslan Ermilov.Ux 1463ce0d6e8SRuslan Ermilovsockets. 14758278509SDag-Erling Smørgrav.It Li LOCAL ADDRESS 148ca007d91SDag-Erling SmørgravFor Internet sockets, this is the address the local end of the socket 149ca007d91SDag-Erling Smørgravis bound to (see 15058278509SDag-Erling Smørgrav.Xr getsockname 2 ) . 151ca007d91SDag-Erling SmørgravFor bound 152ca007d91SDag-Erling Smørgrav.Ux 153ca007d91SDag-Erling Smørgravsockets, it is the socket's filename. 154ca007d91SDag-Erling SmørgravFor other 155ca007d91SDag-Erling Smørgrav.Ux 156ca007d91SDag-Erling Smørgravsockets, it is a right arrow followed by the endpoint's filename, or 157ca007d91SDag-Erling Smørgrav.Dq Li ?? 158ca007d91SDag-Erling Smørgravif the endpoint could not be determined. 15958278509SDag-Erling Smørgrav.It Li FOREIGN ADDRESS 160ac1070c6SDag-Erling Smørgrav(Internet sockets only) 16158278509SDag-Erling SmørgravThe address the foreign end of the socket is bound to (see 16258278509SDag-Erling Smørgrav.Xr getpeername 2 ) . 16349b836f2SMichael Tuexen.It Li ENCAPS 16449b836f2SMichael TuexenThe remote UDP encapsulation port number if 16549b836f2SMichael Tuexen.Fl U 16649b836f2SMichael Tuexenis specified (only for SCTP). 167e389705eSMichael Tuexen.It Li PATH STATE 168e389705eSMichael TuexenThe path state if 169e389705eSMichael Tuexen.Fl s 170e389705eSMichael Tuexenis specified (only for SCTP). 171e389705eSMichael Tuexen.It Li CONN STATE 172e389705eSMichael TuexenThe connection state if 173e5cccc35SMichael Tuexen.Fl s 174e5cccc35SMichael Tuexenis specified (only for SCTP or TCP). 175e5cccc35SMichael Tuexen.It Li STACK 176e5cccc35SMichael TuexenThe protocol stack if 177e5cccc35SMichael Tuexen.Fl S 178e5cccc35SMichael Tuexenis specified (only for TCP). 1792ac089d0SMichael Tuexen.It Li CC 1802ac089d0SMichael TuexenThe congestion control if 1812ac089d0SMichael Tuexen.Fl C 1822ac089d0SMichael Tuexenis specified (only for TCP). 18358278509SDag-Erling Smørgrav.El 18497c6143cSPeter Pentchev.Pp 18561149f8dSJilles TjoelkerIf a socket is associated with more than one file descriptor, 18661149f8dSJilles Tjoelkerit is shown multiple times. 18761149f8dSJilles TjoelkerIf a socket is not associated with any file descriptor, 18861149f8dSJilles Tjoelkerthe first four columns have no meaning. 189f893fe7aSFernando Apesteguía.Sh EXAMPLES 190f893fe7aSFernando ApesteguíaShow information for IPv4 sockets listening on port 22 using protocol 191f893fe7aSFernando ApesteguíaTCP: 192f893fe7aSFernando Apesteguía.Bd -literal -offset indent 193f893fe7aSFernando Apesteguía$ sockstat -4 -l -P tcp -p 22 194f893fe7aSFernando Apesteguía.Ed 195f893fe7aSFernando Apesteguía.Pp 196f893fe7aSFernando ApesteguíaShow information for sockets using either TCP or UDP, if neither, the local nor 197f893fe7aSFernando Apesteguíathe foreign addresses are in the loopback network: 198f893fe7aSFernando Apesteguía.Bd -literal -offset indent 199f893fe7aSFernando Apesteguía$ sockstat -L -P tcp,udp 200f893fe7aSFernando Apesteguía.Ed 201f893fe7aSFernando Apesteguía.Pp 202f893fe7aSFernando ApesteguíaShow TCP IPv6 sockets which are listening and connected (default): 203f893fe7aSFernando Apesteguía.Bd -literal -offset indent 204f893fe7aSFernando Apesteguía$ sockstat -6 -P tcp 205f893fe7aSFernando Apesteguía.Ed 20658278509SDag-Erling Smørgrav.Sh SEE ALSO 20758278509SDag-Erling Smørgrav.Xr fstat 1 , 20814802b60SDag-Erling Smørgrav.Xr netstat 1 , 209e5002279SEdward Tomasz Napierala.Xr procstat 1 , 210482ca427SYoshinobu Inoue.Xr inet 4 , 2111f3d67aaSGiorgos Keramidas.Xr inet6 4 , 2121f3d67aaSGiorgos Keramidas.Xr protocols 5 21358278509SDag-Erling Smørgrav.Sh HISTORY 21458278509SDag-Erling SmørgravThe 21558278509SDag-Erling Smørgrav.Nm 21658278509SDag-Erling Smørgravcommand appeared in 21758278509SDag-Erling Smørgrav.Fx 3.1 . 21858278509SDag-Erling Smørgrav.Sh AUTHORS 21958278509SDag-Erling SmørgravThe 22058278509SDag-Erling Smørgrav.Nm 22158278509SDag-Erling Smørgravcommand and this manual page were written by 2222b7af31cSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . 223