• Linux命令(120)之tcpdump


    linux命令之tcpdump

    1.tcpdump介绍

    linux命令tcpdump是用来将网络中传送的数据包完全截获下来以进行相关分析,常用的分析工具是wireshark

    2.tcpdump用法

    tcpdump [参数]

    tcpdump参数
    参数说明
    -i指定端口
    -n指定协议
    -t在输出的每一行不打印时间戳
    -s抓取数据包时,设置抓取长度,默认为68字节;-s 0为抓取完整的数据包
    -c在收到指定数量的分组后,tcpdump就会停止
    -w定义保存文件名称,默认后缀为.cap,方便使用wireshark工具进行分析

    tcpdump常用关键字

    tcpdump关键字
    关键字包括
    类型关键字host,net,port
    传输方向关键字src,dst
    协议关键字tcp,udp,icmp,ip,arp等
    其它关键字gateway,broadcast,less,greater,not,!,and,or,&&,||

    3.实例

    3.1.抓取ens33网络端口数据包,抓取100次并保存至root目录下

    命令:

    tcpdump -i ens33 -c 100 -w /root/ens33.cap

    1. [root@rhel77 ~]# tcpdump -i ens33 -c 100 -w /root/ens33.cap
    2. tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
    3. 100 packets captured
    4. 101 packets received by filter
    5. 0 packets dropped by kernel
    6. [root@rhel77 ~]# ls -l ens33.cap (使用wireshark进行分析)
    7. -rw-r--r-- 1 tcpdump tcpdump 65910 Nov 13 09:54 ens33.cap
    8. [root@rhel77 ~]#

    3.2.查看tcpdump帮助

    命令:

    man tcpdump

    1. ......
    2. TCPDUMP(8) System Manager's Manual TCPDUMP(8)
    3. NAME
    4. tcpdump - dump traffic on a network
    5. SYNOPSIS
    6. tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
    7. [ -c count ]
    8. [ -C file_size ] [ -G rotate_seconds ] [ -F file ]
    9. [ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
    10. [ --number ] [ -Q|-P in|out|inout ]
    11. [ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
    12. [ -W filecount ]
    13. Manual page tcpdump(8) line 1 (press h for help or q to quit)
    14. ......

  • 相关阅读:
    智慧工地:实现作业区域安全管控
    Linux服务器安装配置Redis
    Android渲染--重温硬件加速上
    学习记录609@python实现数据样本的过采样与欠采样
    python解析pcap报文_scapy解析pcap文件
    工业智能网关BL110应用之六十八: 实现西门子S7-300 PLC接入Modbus TCP Server云平台
    GNU-ncurses库简介
    CSS Grid详解
    Linux Shell入门常用命令使用
    航顺主流替代型HK32F103系列
  • 原文地址:https://blog.csdn.net/z19861216/article/details/134370247