1999-04-15 13:40:43 +00:00
|
|
|
|
.\"-
|
|
|
|
|
.\" Copyright (c) 1999 Dag-Erling Co<43>dan Sm<53>rgrav
|
|
|
|
|
.\" 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
|
|
|
|
.\"
|
2009-07-09 16:40:00 +00:00
|
|
|
|
.Dd July 9, 2009
|
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
|
2008-05-19 11:32:44 +00:00
|
|
|
|
.Op Fl 46cLlu
|
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.
|
2008-05-19 11:32:44 +00:00
|
|
|
|
.It Fl L
|
|
|
|
|
Only show Internet sockets if the local or foreign addresses are not
|
|
|
|
|
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
|
|
|
|
|
Only show Internet sockets if either the local or foreign port number
|
|
|
|
|
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 .
|
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.
|
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
|
2001-08-10 10:43:45 +00:00
|
|
|
|
sockets, or the type of socket (stream or datagram) for
|
|
|
|
|
.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 ) .
|
1999-04-15 13:40:43 +00:00
|
|
|
|
.El
|
2004-08-25 16:36:17 +00:00
|
|
|
|
.Pp
|
|
|
|
|
Note that TCP sockets in the
|
|
|
|
|
.Dv AF_INET
|
|
|
|
|
or
|
|
|
|
|
.Dv AF_INET6
|
|
|
|
|
domains that are not in one of the
|
2005-01-11 10:32:52 +00:00
|
|
|
|
.Dv LISTEN , SYN_SENT ,
|
2004-08-25 16:36:17 +00:00
|
|
|
|
or
|
|
|
|
|
.Dv ESTABLISHED
|
|
|
|
|
states may not be shown by
|
|
|
|
|
.Nm ;
|
|
|
|
|
use
|
|
|
|
|
.Xr netstat 1
|
|
|
|
|
to examine them instead.
|
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
|
2001-08-13 16:33:00 +00:00
|
|
|
|
.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
|
2009-12-21 17:23:04 +00:00
|
|
|
|
.Sh BUGS
|
|
|
|
|
Unlike
|
|
|
|
|
.Xr netstat 1 ,
|
|
|
|
|
.Nm
|
|
|
|
|
lists sockets by walking file descriptor tables and will not output
|
|
|
|
|
the ones owned by the kernel, e.g. NLM sockets created by
|
|
|
|
|
.Xr rpc.lockd 8 .
|