zoukankan      html  css  js  c++  java
  • 利用dsniff的tcpkill杀TCP连接

    利用dsniff的tcpkill杀TCP连接

    Linux连接久久不能释放的现象不常见,但偶然也会发生。进程虽不复存在,但是客户端的连接咬定青山不放松,死活也不肯吐出连接,导致重启进程时因操作系统判断监听端口被占用而无法启动。常规手段已经束手无策,这时候不得不想办法杀连接。
    一、tcpkill介绍
    tcpkill是网络嗅探工具包dsniff其中提供的一个利器,用于杀掉TCP连接。因此事先要安装dsniff。如rhel5中,搜索下载dsniff-2.4-0.1.b1.el5.rf.rpm,rpm -ivh安装后,很容易调出tcpkill命令。我们可以先看看manual:
    [root@xxxx ~]# man tcpkill
    TCPKILL(8)                                                          TCPKILL(8)
    NAME
           tcpkill - kill TCP connections on a LAN
     
    SYNOPSIS
           tcpkill [-i interface] [-1...9] expression
     
    DESCRIPTION
           tcpkill kills specified in-progress TCP connections (useful for libnids-based applications which require a full
           TCP 3-whs for TCB creation).
     
    OPTIONS
           -i interface
                  Specify the interface to listen on.
     
           -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)
    二、tcpkill实战
    在该示例中,FIN_WAIT1 的TCP连接一直无法释放,顽强无比。

    进程监听端口16000,客户端连接端口43255。

    使用tcpkill的效果又是如何呢?

     命令如下:tcpkill -9 host 客户端连接ip

    可以看到客户端140.4:43255的连接被杀掉后,它又重新尝试新的连接。

  • 相关阅读:
    (LeetCode 72)Edit Distance
    (LeetCode 53)Maximum Subarray
    (LeetCode 64)Minimum Path Sum
    (算法)关于随机数的生成
    (笔试题)数组A中任意两个相邻元素大小相差1,在其中查找某个数。
    (笔试题)分椰子
    (笔试题)和0交换的排序
    (笔试题)合法字符串
    (笔试题)被3和5整除的数的和
    (笔试题)程序运行时间
  • 原文地址:https://www.cnblogs.com/archoncap/p/5125180.html
Copyright © 2011-2022 走看看