Today’s applications creates a lot of network connection to the different servers. These connection may legit or unwanted connection. If you are looking a tool that will end the network connection between two host cutter is one of the best solution. Keep in mind that we assume the Linux box sits between hosts or one host in one side.
We will use tcpkill for cutting network connections. Tcpkill tool is provided by dsniff package
sudo apt-get install dsniff -y
sudo yum install dsniff -y
We will first list all connection with netstat command. We want TCP connections and numbered ip addresses.
We will kill connection by providing target connection tcpdump style filter. Tcpdump style filter is the syntax used in tcpdump to filter network traffic. In our situation is very easy. We just provide the ip address and host keyword.
sudo tcpkill -i ens3 port 22
- -i ens3 specifies that we want to use ens3 interfaces for kill operation
- port 22 is our target port where connections will be killed. We kill ssh server so we will disconnect
Our connection is killed and our ssh session ended 🙂