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 46The 47.Nm 48command may be used to drop TCP connections from the command line. 49.Pp 50If 51.Fl a 52is specified then 53.Nm 54will attempt to drop all TCP connections. 55.Pp 56If 57.Fl S Ar stack 58is specified then 59.Nm 60will attempt to drop all connections using the TCP stack 61.Ar stack . 62.Pp 63If 64.Fl s Ar state 65is specified then 66.Nm 67will attempt to drop all TCP connections being in the state 68.Ar state . 69.Ar state 70is 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 81If 82.Fl S Ar stack 83and 84.Fl s Ar state 85are specified, 86.Nm 87will attempt to drop all TCP connections being in the state 88.Ar state 89and using the TCP stack 90.Ar stack . 91Since TCP connections in the 92.Dv TIME_WAIT 93state are not tied to any TCP stack, using the option 94.Fl s Dv TIME_WAIT 95in combination with the 96.Fl S Ar stack 97option results in 98.Nm 99not dropping any TCP connection. 100.Pp 101The 102.Fl l 103flag may be given in addition to the 104.Fl a , 105.Fl S , 106or 107.Fl s 108options to list the tcpdrop invocation to drop all corresponding TCP 109connections one at a time. 110.Pp 111If none of the 112.Fl a , 113.Fl S , 114or 115.Fl s 116options are specified then only the connection between the given local 117address 118.Ar local-address , 119port 120.Ar local-port , 121and the foreign address 122.Ar foreign-address , 123port 124.Ar foreign-port , 125will be dropped. 126.Pp 127Addresses and ports may be specified by name or numeric value. 128Both IPv4 and IPv6 address formats are supported. 129.Pp 130The addresses and ports may be separated by periods or colons 131instead of spaces. 132.Sh EXIT STATUS 133.Ex -std 134.Sh EXAMPLES 135If a connection to 136.Xr httpd 8 137is causing congestion on a network link, one can drop the TCP session 138in charge: 139.Bd -literal -offset indent 140# sockstat -c | grep httpd 141www httpd 16525 3 tcp4 \e 142 192.168.5.41:80 192.168.5.1:26747 143.Ed 144.Pp 145The 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 150The following command will drop all connections but those to or from 151port 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 157The following command will drop all connections using the TCP stack 158fastack: 159.Bd -literal -offset indent 160# tcpdrop -S fastack 161.Ed 162.Pp 163To drop all TCP connections in the LAST_ACK state use: 164.Bd -literal -offset indent 165# tcpdrop -s LAST_ACK 166.Ed 167.Pp 168To drop all TCP connections using the TCP stack fastack and being in the 169LAST_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 181