转载地址:https://www.cnblogs.com/archoncap/p/5125180.html
利用dsniff的tcpkill杀TCP链接html
Linux链接久久不能释放的现象不常见,但偶然也会发生。进程虽不复存在,可是客户端的链接咬定青山不放松,死活也不愿吐出链接,致使重启进程时因操做系统判断监听端口被占用而没法启动。常规手段已经一筹莫展,这时候不得不想办法杀链接。
1、tcpkill介绍
tcpkill是网络嗅探工具包dsniff其中提供的一个利器,用于杀掉TCP链接。所以事先要安装dsniff。如rhel5中,搜索下载dsniff-2.4-0.1.b1.el5.rf.rpm,rpm -ivh安装后,很容易调出tcpkill命令。express
咱们能够先看看manual:
[root@xxxx ~]# man tcpkill
TCPKILL(8) TCPKILL(8)
NAME
tcpkill - kill TCP connections on a LAN网络
SYNOPSIS
tcpkill [-i interface] [-1...9] expressionapp
DESCRIPTION
tcpkill kills specified in-progress TCP connections (useful for libnids-based applications which require a full
TCP 3-whs for TCB creation).tcp
OPTIONS
-i interface
Specify the interface to listen on.ide
-1...9 Specify the degree of brute force to use in killing a connection. Fast connections may require a higher number in order to land a RST in the moving receive window. Default is 3. expression Specify a tcpdump(8) filter expression to select the connections to kill.
SEE ALSO
dsniff(8), tcpnice(8)工具
AUTHOR
Dug Song <dugsong@monkey.org>
TCPKILL(8)
2、tcpkill实战
在该示例中,FIN_WAIT1 的TCP链接一直没法释放,顽强无比。ui
进程监听端口16000,客户端链接端口43255。操作系统
使用tcpkill的效果又是如何呢?code
命令以下:tcpkill -9 host 客户端链接ip
能够看到客户端140.4:43255的链接被杀掉后,它又从新尝试新的链接。
亲测 好用 厉害