]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/tcpdrop/tcpdrop.8
Add two missing eventhandler.h headers
[FreeBSD/FreeBSD.git] / usr.sbin / tcpdrop / tcpdrop.8
1 .\"     $OpenBSD: tcpdrop.8,v 1.5 2004/05/24 13:57:31 jmc Exp $
2 .\"
3 .\" Copyright (c) 2009 Juli Mallett <jmallett@FreeBSD.org>
4 .\" Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
5 .\"
6 .\" Permission to use, copy, modify, and distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
9 .\"
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .\"
18 .\" $FreeBSD$
19 .\"
20 .Dd September 15, 2017
21 .Dt TCPDROP 8
22 .Os
23 .Sh NAME
24 .Nm tcpdrop
25 .Nd drop TCP connections
26 .Sh SYNOPSIS
27 .Nm tcpdrop
28 .Ar local-address
29 .Ar local-port
30 .Ar foreign-address
31 .Ar foreign-port
32 .Nm tcpdrop
33 .Op Fl l
34 .Fl a
35 .Nm tcpdrop
36 .Op Fl l
37 .Fl S Ar stack
38 .Nm tcpdrop
39 .Op Fl l
40 .Fl s Ar state
41 .Nm tcpdrop
42 .Op Fl l
43 .Fl S Ar stack
44 .Fl s Ar state
45 .Sh DESCRIPTION
46 The
47 .Nm
48 command may be used to drop TCP connections from the command line.
49 .Pp
50 If
51 .Fl a
52 is specified then
53 .Nm
54 will attempt to drop all TCP connections.
55 .Pp
56 If
57 .Fl S Ar stack
58 is specified then
59 .Nm
60 will attempt to drop all connections using the TCP stack
61 .Ar stack .
62 .Pp
63 If
64 .Fl s Ar state
65 is specified then
66 .Nm
67 will attempt to drop all TCP connections being in the state
68 .Ar state .
69 .Ar state
70 is one of
71 .Dv SYN_SENT ,
72 .Dv SYN_RCVD ,
73 .Dv ESTABLISHED ,
74 .Dv CLOSE_WAIT ,
75 .Dv FIN_WAIT_1 ,
76 .Dv CLOSING ,
77 .Dv LAST_ACK ,
78 .Dv FIN_WAIT_2 , or
79 .Dv TIME_WAIT .
80 .Pp
81 If
82 .Fl S Ar stack
83 and
84 .Fl s Ar state
85 are specified,
86 .Nm
87 will attempt to drop all TCP connections being in the state
88 .Ar state
89 and using the TCP stack
90 .Ar stack .
91 Since TCP connections in the
92 .Dv TIME_WAIT
93 state are not tied to any TCP stack, using the option
94 .Fl s Dv TIME_WAIT
95 in combination with the
96 .Fl S Ar stack
97 option results in
98 .Nm
99 not dropping any TCP connection.
100 .Pp
101 The
102 .Fl l
103 flag may be given in addition to the
104 .Fl a ,
105 .Fl S ,
106 or
107 .Fl s
108 options to list the tcpdrop invocation to drop all corresponding TCP
109 connections one at a time.
110 .Pp
111 If none of the
112 .Fl a ,
113 .Fl S ,
114 or
115 .Fl s
116 options are specified then only the connection between the given local
117 address
118 .Ar local-address ,
119 port
120 .Ar local-port ,
121 and the foreign address
122 .Ar foreign-address ,
123 port
124 .Ar foreign-port ,
125 will be dropped.
126 .Pp
127 Addresses and ports may be specified by name or numeric value.
128 Both IPv4 and IPv6 address formats are supported.
129 .Pp
130 The addresses and ports may be separated by periods or colons
131 instead of spaces.
132 .Sh EXIT STATUS
133 .Ex -std
134 .Sh EXAMPLES
135 If a connection to
136 .Xr httpd 8
137 is causing congestion on a network link, one can drop the TCP session
138 in charge:
139 .Bd -literal -offset indent
140 # sockstat -c | grep httpd
141 www      httpd      16525 3  tcp4 \e
142         192.168.5.41:80      192.168.5.1:26747
143 .Ed
144 .Pp
145 The following command will drop the connection:
146 .Bd -literal -offset indent
147 # tcpdrop 192.168.5.41 80 192.168.5.1 26747
148 .Ed
149 .Pp
150 The following command will drop all connections but those to or from
151 port 22, the port used by
152 .Xr sshd 8 :
153 .Bd -literal -offset indent
154 # tcpdrop -l -a | grep -vw 22 | sh
155 .Ed
156 .Pp
157 The following command will drop all connections using the TCP stack
158 fastack:
159 .Bd -literal -offset indent
160 # tcpdrop -S fastack
161 .Ed
162 .Pp
163 To drop all TCP connections in the LAST_ACK state use:
164 .Bd -literal -offset indent
165 # tcpdrop -s LAST_ACK
166 .Ed
167 .Pp
168 To drop all TCP connections using the TCP stack fastack and being in the
169 LAST_ACK state use:
170 .Bd -literal -offset indent
171 # tcpdrop -S fastack -s LAST_ACK
172 .Ed
173 .Sh SEE ALSO
174 .Xr netstat 1 ,
175 .Xr sockstat 1 ,
176 .Xr tcp 4 ,
177 .Xr tcp_functions 9
178 .Sh AUTHORS
179 .An Markus Friedl Aq Mt markus@openbsd.org
180 .An Juli Mallett Aq Mt jmallett@FreeBSD.org