Linux下抓包命令tcpflow使用总结

来源:互联网 发布:供应商管理数据库 编辑:程序博客网 时间:2024/05/16 08:42

tcpflow实际上也是一个抓包工具,这个抓包工具与tcpdump不同的是它是以流为单位显示数据内容,而cpdump以包为单位显示数据。我们平常会经常分析HTTP数据,用tcpflow会更便捷。

tcpflow可以理解为是一个抓包工具,其工具看起来更像wireshark的命令行版本,他可以直接从网卡抓包,并且解析出来,支持http ftp这些L7协议,也支持tcp udp抓包,还可以从tcpdump中读取东西,因此是一个非常好的看包工具,有了这个东西以后再也不用把线上服务器上的dump抓下来再用wireshark打开了。

tcpdump使用方法:

例1:在负载均衡器上分析其负载分发状况,在负载均衡服务器上执行

tcpflow -cp host 172.23.232.145(后端 IP)

例2:看缓存服务器上缓存有没有命中,在缓存服务器上执行

tcpflow -cp host 172.23.232.145(源端IP) | grep /index.html (url的相对路径) -A 10

可以根据自己需要自己去定义过滤,用法与tcpdump类似。

tcpflow version 0.21 by Jeremy Elson <jelson@circlemud.org>

usage: tcpflow [-chpsv] [-b max_bytes] [-d debug_level] [-f max_fds]
          [-i iface] [-w file] [expression]
        -b: max number of bytes per flow to save
        -c: console print only (don't create files)
        -d: debug level; default is 1
        -f: maximum number of file descriptors to use
        -h: print this help message
        -i: network interface on which to listen
            (type "ifconfig -a" for a list of interfaces)
        -p: don't use promiscuous mode
        -r: read packets from tcpdump output file
        -s: strip non-printable characters (change to '.')
        -v: verbose operation equivalent to -d 10
expression: tcpdump-like filtering expression

0 0
原创粉丝点击