1999-04-15 13:40:43 +00:00
|
|
|
.\"-
|
2011-12-30 10:59:15 +00:00
|
|
|
.\" Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
|
1999-04-15 13:40:43 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer
|
|
|
|
.\" in this position and unchanged.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1999-04-15 13:40:43 +00:00
|
|
|
.\"
|
2018-07-03 23:47:20 +00:00
|
|
|
.Dd July 3, 2018
|
1999-09-06 13:14:24 +00:00
|
|
|
.Dt SOCKSTAT 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1999-04-15 13:40:43 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm sockstat
|
2000-10-07 14:11:43 +00:00
|
|
|
.Nd list open sockets
|
1999-04-15 13:40:43 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2017-09-13 06:57:52 +00:00
|
|
|
.Op Fl 46cLlSsUuvw
|
2012-05-24 01:31:10 +00:00
|
|
|
.Op Fl j Ar jid
|
2001-08-07 19:59:52 +00:00
|
|
|
.Op Fl p Ar ports
|
2006-11-11 22:11:54 +00:00
|
|
|
.Op Fl P Ar protocols
|
1999-04-15 13:40:43 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
2001-08-10 10:43:45 +00:00
|
|
|
command lists open Internet or
|
|
|
|
.Ux
|
|
|
|
domain sockets.
|
2000-10-07 14:11:43 +00:00
|
|
|
.Pp
|
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width Fl
|
|
|
|
.It Fl 4
|
2001-08-10 10:43:45 +00:00
|
|
|
Show
|
|
|
|
.Dv AF_INET
|
|
|
|
(IPv4) sockets.
|
2000-10-07 14:11:43 +00:00
|
|
|
.It Fl 6
|
2001-08-10 10:43:45 +00:00
|
|
|
Show
|
|
|
|
.Dv AF_INET6
|
|
|
|
(IPv6) sockets.
|
2001-03-06 13:48:38 +00:00
|
|
|
.It Fl c
|
|
|
|
Show connected sockets.
|
2018-07-03 23:47:20 +00:00
|
|
|
.It Fl j Ar jail
|
|
|
|
Show only sockets belonging to the specified jail ID or name.
|
2008-05-19 11:32:44 +00:00
|
|
|
.It Fl L
|
2015-06-13 20:15:44 +00:00
|
|
|
Only show Internet sockets if the local and foreign addresses are not
|
2008-05-19 11:32:44 +00:00
|
|
|
in the loopback network prefix
|
|
|
|
.Li 127.0.0.0/8 ,
|
|
|
|
or do not contain the IPv6 loopback address
|
|
|
|
.Li ::1 .
|
2001-03-06 13:48:38 +00:00
|
|
|
.It Fl l
|
|
|
|
Show listening sockets.
|
2001-08-07 19:59:52 +00:00
|
|
|
.It Fl p Ar ports
|
2015-04-07 14:33:03 +00:00
|
|
|
Only show Internet sockets if the local or foreign port number
|
2001-08-07 19:59:52 +00:00
|
|
|
is on the specified list.
|
|
|
|
The
|
|
|
|
.Ar ports
|
|
|
|
argument is a comma-separated list of port numbers and ranges
|
|
|
|
specified as first and last port separated by a dash.
|
2006-11-11 22:11:54 +00:00
|
|
|
.It Fl P Ar protocols
|
|
|
|
Only show sockets of the specified
|
|
|
|
.Ar protocols .
|
|
|
|
The
|
|
|
|
.Ar protocols
|
|
|
|
argument is a comma-separated list of protocol names,
|
|
|
|
as they are defined in
|
|
|
|
.Xr protocols 5 .
|
2018-01-23 13:03:47 +00:00
|
|
|
.It Fl q
|
|
|
|
Quiet mode, do not print the header line.
|
2017-09-12 13:34:43 +00:00
|
|
|
.It Fl S
|
|
|
|
Display the protocol stack, if applicable.
|
|
|
|
This is currently only implemented for TCP.
|
2015-07-16 13:09:21 +00:00
|
|
|
.It Fl s
|
|
|
|
Display the protocol state, if applicable.
|
2015-08-26 23:45:06 +00:00
|
|
|
This is currently only implemented for SCTP and TCP.
|
2017-09-12 21:07:48 +00:00
|
|
|
.It Fl U
|
|
|
|
Display the remote UDP encapsulation port number, if applicable.
|
|
|
|
This is currently only implemented for SCTP.
|
2000-10-07 14:11:43 +00:00
|
|
|
.It Fl u
|
2001-08-10 10:43:45 +00:00
|
|
|
Show
|
|
|
|
.Dv AF_LOCAL
|
|
|
|
.Pq Ux
|
|
|
|
sockets.
|
2017-09-13 06:57:52 +00:00
|
|
|
.It Fl v
|
|
|
|
Verbose mode.
|
|
|
|
.It Fl w
|
|
|
|
Use wider field size for displaying addresses.
|
2000-10-07 14:11:43 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2001-03-06 13:48:38 +00:00
|
|
|
If neither
|
2001-08-10 10:43:45 +00:00
|
|
|
.Fl 4 , 6
|
2001-03-06 13:48:38 +00:00
|
|
|
or
|
|
|
|
.Fl u
|
|
|
|
is specified,
|
2000-10-07 14:11:43 +00:00
|
|
|
.Nm
|
2001-03-06 13:48:38 +00:00
|
|
|
will list sockets in all three domains.
|
|
|
|
.Pp
|
|
|
|
If neither
|
|
|
|
.Fl c
|
|
|
|
or
|
|
|
|
.Fl l
|
|
|
|
is specified,
|
|
|
|
.Nm
|
|
|
|
will list both listening and connected sockets.
|
2000-10-07 14:11:43 +00:00
|
|
|
.Pp
|
2000-03-01 12:20:22 +00:00
|
|
|
The information listed for each
|
1999-04-15 13:40:43 +00:00
|
|
|
socket is:
|
1999-07-06 19:12:31 +00:00
|
|
|
.Bl -tag -width "FOREIGN ADDRESS"
|
1999-04-15 13:40:43 +00:00
|
|
|
.It Li USER
|
|
|
|
The user who owns the socket.
|
|
|
|
.It Li COMMAND
|
|
|
|
The command which holds the socket.
|
|
|
|
.It Li PID
|
|
|
|
The process ID of the command which holds the socket.
|
|
|
|
.It Li FD
|
|
|
|
The file descriptor number of the socket.
|
|
|
|
.It Li PROTO
|
2000-10-07 14:11:43 +00:00
|
|
|
The transport protocol associated with the socket for Internet
|
2015-06-20 08:59:50 +00:00
|
|
|
sockets, or the type of socket
|
|
|
|
.Pq stream, datagram, or seqpacket
|
|
|
|
for
|
2001-08-10 10:43:45 +00:00
|
|
|
.Ux
|
|
|
|
sockets.
|
1999-04-15 13:40:43 +00:00
|
|
|
.It Li LOCAL ADDRESS
|
2002-07-31 12:32:03 +00:00
|
|
|
For Internet sockets, this is the address the local end of the socket
|
|
|
|
is bound to (see
|
2001-01-16 09:39:23 +00:00
|
|
|
.Xr getsockname 2 ) .
|
2002-11-26 17:33:37 +00:00
|
|
|
For bound
|
|
|
|
.Ux
|
2002-07-31 12:32:03 +00:00
|
|
|
sockets, it is the socket's filename.
|
2002-11-26 17:33:37 +00:00
|
|
|
For other
|
|
|
|
.Ux
|
2002-07-31 12:32:03 +00:00
|
|
|
sockets, it is a right arrow followed by the endpoint's filename, or
|
|
|
|
.Dq Li ??
|
|
|
|
if the endpoint could not be determined.
|
1999-04-15 13:40:43 +00:00
|
|
|
.It Li FOREIGN ADDRESS
|
2000-10-07 14:11:43 +00:00
|
|
|
(Internet sockets only)
|
1999-04-15 13:40:43 +00:00
|
|
|
The address the foreign end of the socket is bound to (see
|
2001-01-16 09:39:23 +00:00
|
|
|
.Xr getpeername 2 ) .
|
2017-09-12 21:07:48 +00:00
|
|
|
.It Li ENCAPS
|
|
|
|
The remote UDP encapsulation port number if
|
|
|
|
.Fl U
|
|
|
|
is specified (only for SCTP).
|
2017-09-12 21:36:13 +00:00
|
|
|
.It Li PATH STATE
|
|
|
|
The path state if
|
|
|
|
.Fl s
|
|
|
|
is specified (only for SCTP).
|
|
|
|
.It Li CONN STATE
|
|
|
|
The connection state if
|
2017-09-12 13:34:43 +00:00
|
|
|
.Fl s
|
|
|
|
is specified (only for SCTP or TCP).
|
|
|
|
.It Li STACK
|
|
|
|
The protocol stack if
|
|
|
|
.Fl S
|
|
|
|
is specified (only for TCP).
|
1999-04-15 13:40:43 +00:00
|
|
|
.El
|
2004-08-25 16:36:17 +00:00
|
|
|
.Pp
|
2012-01-24 21:33:34 +00:00
|
|
|
If a socket is associated with more than one file descriptor,
|
|
|
|
it is shown multiple times.
|
|
|
|
If a socket is not associated with any file descriptor,
|
|
|
|
the first four columns have no meaning.
|
1999-04-15 13:40:43 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr fstat 1 ,
|
1999-07-06 19:12:31 +00:00
|
|
|
.Xr netstat 1 ,
|
2009-07-09 16:40:00 +00:00
|
|
|
.Xr procstat 1 ,
|
2000-02-26 02:56:16 +00:00
|
|
|
.Xr inet 4 ,
|
2006-11-11 22:11:54 +00:00
|
|
|
.Xr inet6 4 ,
|
|
|
|
.Xr protocols 5
|
1999-04-15 13:40:43 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.Fx 3.1 .
|
|
|
|
.Sh AUTHORS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command and this manual page were written by
|
2014-06-23 08:23:05 +00:00
|
|
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
|