杀死TCP连接

问候,

我正在testing应用程序在Linux上,我们有一个数据库连接相关的错误,因为数据库连接不能重新启动,它是在远程计算机上,我想杀了TCP连接,以中断连接,看到行为。

拔掉网线也不是一个select! 我没有两台机器的物理访问权限。

我使用iptables,但是我的系统没有iptables,所以我的项目经理告诉我使用tcpkill来完成这个任务。

有人可以告诉我在哪里可以得到tcpkill rpm,并给我一些关于如何使用它的提示?

ip route blackhole添加一个空路由,假设你有root用户:

[root@centos6 ~]# nc -zv 192.168.15.100 80 Connection to 192.168.15.100 80 port [tcp/http] succeeded! [root@centos6 ~]# ip route add blackhole 192.168.15.100 [root@centos6 ~]# nc -zv 192.168.15.100 80 nc: connect to 192.168.15.100 port 80 (tcp) failed: Network is unreachable [root@centos6 ~]# ip route delete blackhole 192.168.15.100 [root@centos6 ~]# nc -zv 192.168.15.100 80 Connection to 192.168.15.100 80 port [tcp/http] succeeded! 

编辑:如果你有在机器上,应用程序通过FQDN连接到数据库,添加一个FQDN并将FQDN指向一个虚拟地址。 尽pipe如此,tcp连接可能需要一段时间。

再次编辑:好的,我错过了关于tcpkill的部分。 🙂

它在EPEL中可用,如果您正在运行CentOS或Scientific Linux,则启用EPEL回购以便您可以find它:

 [root@kerberos rsync-dist]# yum whatprovides "*/tcpkill" --enablerepo=epel Loaded plugins: refresh-packagekit epel/metalink | 9.0 kB 00:00 epel | 4.3 kB 00:00 epel/primary_db | 4.3 MB 00:05 epel/filelists_db | 5.5 MB 00:07 dsniff-2.4-0.9.b1.el6.x86_64 : Tools for network auditing and penetration testing Repo : epel Matched from: Filename : /usr/sbin/tcpkill 

确保使用–enablerepo,以便可以从那里安装,如下所示:

 yum -y install dsniff --enablerepo=epel 

你可以在这里阅读说明:

http://www.cyberciti.biz/howto/question/linux/kill-tcp-connection-using-linux-netstat.php

例:

 tcpkill ip host 192.168.1.2 and not 192.168.1.111