Killing linux socket from shell (gentoo amd64)
Asked Answered
T

2

6

Folks, what is the best way to kill an established connection from the shell in linux?

Looks like there are 'tcpkill' and 'cutter' tools available, however, on my gentoo amd64 tcpkill is disabled by the 'amd64' keyword and cutter, when used, prints an error "openning /proc/net/ip_conntrack: No such file or directory".

Is there any other way to kill the connection?

Thanks.

Tremble answered 25/6, 2009 at 10:3 Comment(2)
tried running modprobe ip_conntrack?Rao
Well, I can give it a try... But I'm quite amazed that a kernel module is required for such basic stuff.Tremble
B
5

The 2.4_beta1-r4 of dsniff (containing tcpkill) is "only" marked as ~amd64, so you might want to give it a shot anyway.
(not exactly a programming question though...)

Biforked answered 25/6, 2009 at 10:20 Comment(2)
Thanks, I installed tcpkill by putting to package.keywords net-libs/libnids and net-analyzer/dsniff and it's working as expected. However I'm pretty surprised I had to install some 3d party tools for such really basic stuff.Tremble
Usually there is no good reason to kill a random connection while leaving the program owning the connection alive except if you are writing a program and want to test how it handles disconnects.Academia
V
-1

Any particular reason you can't use kill or pkill (along with netstat) to find the process which has the connection, and then kill it?

Vituline answered 25/6, 2009 at 14:50 Comment(2)
He's asking about killing a connection, not a processRao
This is true. Killing the process which has established the TCP connection also ends the connection - and that is the only reason I mentioned it, as an alternative (haha, and not knowing any more about the requirements of the OP!)Vituline

© 2022 - 2024 — McMap. All rights reserved.