使用 tcpdump 捕获网络数据报文

发布于 2022-04-05 12:53:23 字数 1795 浏览 1180 评论 0

捕获指定网卡

获取可用网卡列表

# tcpdump -D

捕获指定的网卡

# tcpdump -i <interface_name>

捕获的报文实时存储到文件

# tcpdump -w <file_name>

设定捕获时报文过滤器

# tcpdump -i <interface_name> -w <file_name> [ expression ]

如上[ expression ] 处填写报文过滤规则,规则定义如下:

TCPDUMP SYNTAX

Syntax:ProtocolDirectionHost(s)ValueLogical OperationsOther expression
Example:tcpdst10.1.1.180andtcp dst 10.2.2.2 3128
  • Protocol:

Values: ether, fddi, ip, arp, rarp, decnet, lat, sca, moprc, mopdl, tcp and udp.

If no protocol is specified, all the protocols are used.

  • Direction:

Values: src, dst, src and dst, src or dst

If no source or destination is specified, the "src or dst" keywords are applied.

For example, "host 10.2.2.2" is equivalent to "src or dst host 10.2.2.2".

  • Host(s):

Values: net, port, host, portrange.

If no host(s) is specified, the "host" keyword is used.

For example, "src 10.1.1.1" is equivalent to "src host 10.1.1.1".

  • Logical Operations:

Values: not, and, or.

Negation ("not") has highest precedence. Alternation ("or") and concatenation ("and") have equal precedence and associate left to right.

For example,

"not tcp port 3128 and tcp port 23" is equivalent to "(not tcp port 3128) and tcp port 23".
"not tcp port 3128 and tcp port 23" is NOT equivalent to "not (tcp port 3128 and tcp port 23)".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

JSmiles

生命进入颠沛而奔忙的本质状态,并将以不断告别和相遇的陈旧方式继续下去。

0 文章
0 评论
84959 人气
更多

推荐作者

花开柳相依

文章 0 评论 0

zyhello

文章 0 评论 0

故友

文章 0 评论 0

对风讲故事

文章 0 评论 0

Oo萌小芽oO

文章 0 评论 0

梦明

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文