How to kill a TCP connection using tcpkill utility
Solution 1:
For tcpkill to work (i.e., craft a reset packet that has the correct sequence number and source port), there must be traffic. If nothing more is printed then there is no traffic. To verify you could run tcpdump -i eth1 port 443
.
Solution 2:
I had to kill an established connection on which there was no traffic (a debug session on a JVM).
tcpkill
as explained in @Mark Wagner answer could not do it, however killcx
1.0.3 (link) did (Ubuntu 10.04).
It is a perl script that has a dependency on a few libraries.
Edit
On a connection that could not be killed with killcx
the combination of both tcpkill
and killcx
did it:
Say the connection if from LOCAL:PORTL
to REMOTE:PORTR
- In a terminal start tcpkill:
tcpkill port PORTL
. Tcpkill will start listening for traffic - In a second terminal launch killcx:
killcx REMOTE:PORTR