12

I'm trying to kill an ESTABLISHED TCP connection using tcpkill. The connection is an open HTTPS connection. It appears on netstat as:

tcp        0      0 X.X.X.X:55601         X.X.X.X:https    ESTABLISHED

So, as per the man page, I enter:

$ tcpkill -i eth1 -9 port 443

The tcpkill utility outputs:

tcpkill: listening on eth1 [port 443]

...and then just hangs. After waiting for about 15 minutes, I'm not sure what's going on here.

Am I doing something wrong?

1
  • I had the same problem and I was just using the wrong interface (eth0 instead of lo), the answer from Marl helped me a lot serverfault.com/a/315728/277736
    – thomas
    Sep 6, 2023 at 5:22

3 Answers 3

13

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.

3

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
1

I found that I needed to specify the local (source) port, not the remote port, ie.

$ sudo netstat -np | grep myclient
tcp        0      0 x.x.x.x:46844 y.y.y.y:https ESTABLISHED 1234/myclient
$ sudo tcpkill -i eth0 port 46844
tcpkill: listening on eth0 [port 46844]
... [output which shows tcpkill working, once there is traffic] ...

So in your case it should be:

$ tcpkill -i eth1 -9 port 55601

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .