Today’s applications create a lot of network connection to the different servers. This connection may legit or unwanted connection. If you are looking for a tool that will end the network connection between two host cutter is one of the best solutions. Keep in mind that we assume the Linux box sits between hosts or one host in one side.
当今的应用程序创建了到不同服务器的大量网络连接。 此连接可能是合法的连接,也可能是不需要的连接。 如果您正在寻找一种可以终止两个主机切割器之间的网络连接的工具,则是最佳的解决方案之一。 请记住,我们假设Linux盒位于主机之间或一侧中的一台主机之间。
安装Tcpkill (Install Tcpkill)
We will use tcpkill for cutting network connections. Tcpkill tool is provided by dsniff package
我们将使用tcpkill断开网络连接。 dsniff软件包提供了Tcpkill工具
Ubuntu,Debian,Mint和Kali(Ubuntu, Debian, Mint, and Kali)
We will install the following command in order to install dsniff in deb based distributions.
我们将安装以下命令,以便在基于deb的发行版中安装dsniff。
$ sudo apt-get install dsniff -y
CentOS,Fedora,Red Hat (CentOS, Fedora, Red Hat)
We can install dsniff for rpm-based distributions like below.
我们可以为基于rpm的发行版安装dsniff,如下所示。
$ sudo yum install dsniff -y
列出网络连接 (List Network Connections)
We will first list all connection with netstat
command. We want TCP connections and numbered IP addresses.
我们将首先使用netstat
命令列出所有连接。 我们需要TCP连接和编号的IP地址。
$ netstat -tn
列出网络接口(List Network Interface)
tcpkill is also required the network interface name in order to kill a network connection. We can list network interfaces in different ways but the most easy and fast way is using ip link
command like below.
还必须使用tcpkill网络接口名称才能终止网络连接。 我们可以用不同的方式列出网络接口,但是最简单快捷的方法是使用如下所示的ip link
命令。
$ ip link
终止连接(Kill Connection)
We will kill connection by providing a 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.
我们将通过提供目标连接tcpdump样式过滤器来终止连接。 Tcpdump样式过滤器是tcpdump中用于过滤网络流量的语法。 在我们的情况下非常容易。 我们只提供IP地址和主机关键字。
$ sudo tcpkill -i ens3 port 22
- `-i ens3specifies that we want to use ens3 interfaces for kill operation`-i ens3指定我们要使用ens3接口进行kill操作
- port 22is our target port where connections will be killed. We kill ssh server so we will disconnect 端口22是我们将终止连接的目标端口。 我们杀死了ssh服务器,所以我们将断开连接
翻译自: https://www.poftut.com/cut-existing-network-connection-linux/