linux
  • Introduction
  • Yum
    • 基础yum源的配置
    • 为yum源配置代理
    • Centos指定版本的yum源
    • 环境变量
    • 本地yum源
    • 制作yum源
      • 同步yum源
    • epel源
  • Iptables
    • 基本匹配条件
    • Match-Extensions
      • Addrtype
      • Set
      • TCP
    • Target-Extensions
      • DNAT
      • LOG
    • Iptables规则持久化
    • 连接追踪
  • LVS
    • Ipvsadm命令
  • 磁盘与分区
    • 创建分区
    • 格式化与挂载
    • fstab
    • LVM
      • LVM扩容
    • swap分区
    • tmpfs
  • 网络相关
    • 重命名网卡
    • resolv.conf
    • Tcpdump
    • dig与nslookup
  • Other
    • CPU与内存
    • 进程
      • 僵尸进程
    • SSH密钥登录
    • 用户管理
    • Crontab
  • Nofile
    • 原理
  • 常用软件安装篇
    • MYSQL
    • 系统与内核
      • 指定内核启动
    • NFS
    • Haproxy
    • Keepalived
    • Squid
    • Redsocks
    • Shadowsocks
    • 时钟同步
  • 内存
Powered by GitBook
On this page
  • 常用格式
  • 关键字类型
  • 1、host、net、port
  • 2、src、dst
  • 3、逻辑关键字: and、or、not
  • 4、协议关键字:tcp、udp、icmp等
  • 选项(Options)
  • 1、 -i bond0
  • Reference

Was this helpful?

  1. 网络相关

Tcpdump

常用格式

$ tcpdump -vvvnn -i bond0 tcp 'src host x.x.x.x and src port xx' or 'dst host x.x.x.x and dst port xx'

关键字类型

1、host、net、port

第一类关键字为host、net、port三个。

比如,监听主机的IP为x.x.x.x的数据包

$ tcpdump host x.x.x.x

比如,监听网络为x.x.x.x/24的数据包

$ tcpdump net x.x.x.x/24

比如,监听端口为xx的数据包

$ tcpdump port xx

2、src、dst

第二类关键字表示数据包的流向,它们用来修饰第一类关键字

比如,监听源主机为x.x.x.x的数据包

$ tcpdump src host x.x.x.x

如果第一类关键字(host、net、port)没有指定src或dst修饰,则默认为src(待验证)

3、逻辑关键字: and、or、not

比如

$ tcpdump dst host x.x.x.x and dst port xx
$ tcpdump 'src host x.x.x.x and src port xx' or 'dst host y.y.y.y and dst port yy'
$ tcpdump dst host x.x.x.x and not dst port xx

4、协议关键字:tcp、udp、icmp等

比如,监听协议为tcp的包

$ tcpdump tcp

选项(Options)

1、 -i bond0

-i可以指定监听特定网卡的数据包,比如监听网卡bond0的数据包

$ tcpdump -i bond0

注意:如果该选项没有指定,则默认监听第一个网卡(一般以字母开头升序排序)的数据包

Reference

Previousresolv.confNextdig与nslookup

Last updated 5 years ago

Was this helpful?

https://www.cnblogs.com/maifengqiang/p/3863168.html
https://linuxwiki.github.io/NetTools/tcpdump.html