• linux下tcpdump命令的使用


    一般情况下linux系统会自带tcpdump工具,如果系统没有安装,直接用命令安装就行了。

    安装命令:yum install -y tcpdump

    查看安装版本命令:tcpdump --help

    查看网卡命令:

    知道了网卡,就可以使用tcpdump工具针对服务器上的网卡监控、过滤网络数据。

    tcpdump常用命令:

    #抓取所有经过 eth0,目的或源地址是 192.168.29.162 的网络数据
    命令:tcpdump -n -i eth0 host 192.168.29.162

    # 源地址
    命令:tcpdump -i eth1 src host 192.168.29.162
    # 目的地址
    命令:tcpdump -i eth1 dst host 192.168.29.162

    #抓取当前服务器eth0网卡端口8080的网络数据
    命令:tcpdump -n -i eth0 port 8080

    #抓取mysql执行的sql语句
    命令:tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings

    #抓取mysql通讯的网络包(cap用wireshark打开)
    命令tcpdump -n -nn -tttt -i eth0 -s 65535 'port 3306' -w 20160505mysql.cap

    #抓取SMTP 数据
    命令:tcpdump -i eth1 'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack != 0'

    #抓取HTTP GET数据,"GET "的十六进制是 47455420
    命令:tcpdump -i eth1 'tcp[(tcp[12]>>2):4] = 0x47455420'

    #抓取SSH返回,"SSH-"的十六进制是 0x5353482D
    命令:tcpdump -i eth1 'tcp[(tcp[12]>>2):4] = 0x5353482D'

    #实时抓取端口号8080的GET包,然后写入GET.log
    命令:tcpdump -i eth0 '((port 8080) and (tcp[(tcp[12]>>2):4]=0x47455420))' -nnAl -w /tmp/GET.log

    #抓取指定SYN个数,-c 参数指定抓多少个包。
    命令:time tcpdump -nn -i eth0 'tcp[tcpflags] = tcp-syn' -c 10

  • 相关阅读:
    QEMU KVM Libvirt手册(10):Managing Virtual Machines with libvirt
    Openssl的证书操作
    QEMU KVM Libvirt手册(10): KVM的各种限制
    QEMU KVM Libvirt手册(9): network
    nginx调优(一)
    Apache调优(二)
    Apache调优(一)
    使用Varnish为网站加速
    Linux系统调优——系统整体运行状态排查(六)
    Linux系统调优——内核相关参数(五)
  • 原文地址:https://www.cnblogs.com/luihengk/p/6840795.html
Copyright © 2020-2023  润新知