xref: /freebsd/usr.bin/sockstat/sockstat.1 (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
1.\"-
2.\" Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer
10.\"    in this position and unchanged.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
30.Dd January 23, 2018
31.Dt SOCKSTAT 1
32.Os
33.Sh NAME
34.Nm sockstat
35.Nd list open sockets
36.Sh SYNOPSIS
37.Nm
38.Op Fl 46cLlSsUuvw
39.Op Fl j Ar jid
40.Op Fl p Ar ports
41.Op Fl P Ar protocols
42.Sh DESCRIPTION
43The
44.Nm
45command lists open Internet or
46.Ux
47domain sockets.
48.Pp
49The following options are available:
50.Bl -tag -width Fl
51.It Fl 4
52Show
53.Dv AF_INET
54(IPv4) sockets.
55.It Fl 6
56Show
57.Dv AF_INET6
58(IPv6) sockets.
59.It Fl c
60Show connected sockets.
61.It Fl j Ar jid
62Show only sockets belonging to the specified jail ID.
63.It Fl L
64Only show Internet sockets if the local and foreign addresses are not
65in the loopback network prefix
66.Li 127.0.0.0/8 ,
67or do not contain the IPv6 loopback address
68.Li ::1 .
69.It Fl l
70Show listening sockets.
71.It Fl p Ar ports
72Only show Internet sockets if the local or foreign port number
73is on the specified list.
74The
75.Ar ports
76argument is a comma-separated list of port numbers and ranges
77specified as first and last port separated by a dash.
78.It Fl P Ar protocols
79Only show sockets of the specified
80.Ar protocols .
81The
82.Ar protocols
83argument is a comma-separated list of protocol names,
84as they are defined in
85.Xr protocols 5 .
86.It Fl q
87Quiet mode, do not print the header line.
88.It Fl S
89Display the protocol stack, if applicable.
90This is currently only implemented for TCP.
91.It Fl s
92Display the protocol state, if applicable.
93This is currently only implemented for SCTP and TCP.
94.It Fl U
95Display the remote UDP encapsulation port number, if applicable.
96This is currently only implemented for SCTP.
97.It Fl u
98Show
99.Dv AF_LOCAL
100.Pq Ux
101sockets.
102.It Fl v
103Verbose mode.
104.It Fl w
105Use wider field size for displaying addresses.
106.El
107.Pp
108If neither
109.Fl 4 , 6
110or
111.Fl u
112is specified,
113.Nm
114will list sockets in all three domains.
115.Pp
116If neither
117.Fl c
118or
119.Fl l
120is specified,
121.Nm
122will list both listening and connected sockets.
123.Pp
124The information listed for each
125socket is:
126.Bl -tag -width "FOREIGN ADDRESS"
127.It Li USER
128The user who owns the socket.
129.It Li COMMAND
130The command which holds the socket.
131.It Li PID
132The process ID of the command which holds the socket.
133.It Li FD
134The file descriptor number of the socket.
135.It Li PROTO
136The transport protocol associated with the socket for Internet
137sockets, or the type of socket
138.Pq stream, datagram, or seqpacket
139for
140.Ux
141sockets.
142.It Li LOCAL ADDRESS
143For Internet sockets, this is the address the local end of the socket
144is bound to (see
145.Xr getsockname 2 ) .
146For bound
147.Ux
148sockets, it is the socket's filename.
149For other
150.Ux
151sockets, it is a right arrow followed by the endpoint's filename, or
152.Dq Li ??
153if the endpoint could not be determined.
154.It Li FOREIGN ADDRESS
155(Internet sockets only)
156The address the foreign end of the socket is bound to (see
157.Xr getpeername 2 ) .
158.It Li ENCAPS
159The remote UDP encapsulation port number if
160.Fl U
161is specified (only for SCTP).
162.It Li PATH STATE
163The path state if
164.Fl s
165is specified (only for SCTP).
166.It Li CONN STATE
167The connection state if
168.Fl s
169is specified (only for SCTP or TCP).
170.It Li STACK
171The protocol stack if
172.Fl S
173is specified (only for TCP).
174.El
175.Pp
176If a socket is associated with more than one file descriptor,
177it is shown multiple times.
178If a socket is not associated with any file descriptor,
179the first four columns have no meaning.
180.Sh SEE ALSO
181.Xr fstat 1 ,
182.Xr netstat 1 ,
183.Xr procstat 1 ,
184.Xr inet 4 ,
185.Xr inet6 4 ,
186.Xr protocols 5
187.Sh HISTORY
188The
189.Nm
190command appeared in
191.Fx 3.1 .
192.Sh AUTHORS
193The
194.Nm
195command and this manual page were written by
196.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
197