• Linux下使用 tcpdump 抓包


    1,监视指定网络接口数据包

    tcpdump -i eth1

    如果不指定网卡,默认tcpdump 只会监视第一个网络接口,一般是eth0。

    2,监视指定主机的数据包,打印所有进入或离开eureka1.com的数据包。

    tcpdump host eureka1.com

    或者可以抓取指定ip收到和发出的所有数据包。

    tcpdump host 192.168.2.252

    3,监视指定主机和指定端口的tcp数据包

    tcpdump tcp port 7001 and host 192.168.2.252

    4,tcpdump 与 wireshark Wireshark(以前是ethereal)是Windows下非常简单易用的抓包工具。但在Linux下很难找到一个好用的图形化抓包工具。还好有Tcpdump。

    我们可以用Tcpdump + Wireshark 的完美组合实现:在 Linux 里抓包,然后在Windows 里分析包。

    tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 7001 and src net 192.168.2.252 -w ./target.cap

    (1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型.
    (2)-i eth1 : 只抓经过接口eth1的包。
    (3)-t : 不显示时间戳。
    (4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-S 0 后可以抓到完整的数据包。
    (5)-c 100 : 只抓取100个数据包。
    (6)dst port ! 7001 : 不抓取目标端口是7001的数据包。
    (7)src net 192.168.2.252 : 数据包的源网络地址为192.168.2.252。
    (8)-w ./local.cap : 保存成cap文件,方便用ethereal(即wireshark)分析。

  • 相关阅读:
    springboot 整合jdbcTemplate
    springboot 整合springDataJPA
    springboot 全局异常处理
    springboot整合jsp模板
    springboot整合mybatis+pageHelper
    springboot整合mybatis
    springboot使用fastJson作为json解析框架
    springBoot开启热部署
    springboot快速入门
    解决springboot启动失败问题:Unable to start embedded container;
  • 原文地址:https://www.cnblogs.com/tooker/p/14690864.html
Copyright © 2020-2023  润新知