如何在Linux中切断现有的网络连接?

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
Ubuntu, Debian, Mint, and Kali
Ubuntu, Debian, Mint, and Kali
Ubuntu,Debian,Mint和Kali

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 Connections
List Network Connections
列出网络连接

列出网络接口(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
List Network Interface
List Network Interface
列出网络接口

终止连接(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
Kill Connection
Kill Connection
终止连接
  • `-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服务器,所以我们将断开连接
LEARN MORE  How To Change Cisco IOS Time?
了解更多如何更改Cisco IOS时间?

翻译自: https://www.poftut.com/cut-existing-network-connection-linux/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值