PCAP 过滤器如何捕获所有与 DHCP 相关的流量?

Mat*_*ner 6 dhcp wireshark tcpdump pcap

据我了解,对于 IPv4,我需要捕获

  • UDP 端口 67 和 68,
  • ARP,
  • ICMP 回显请求和回复,

对于 IPv6 我需要

  • UDP 端口 546 和 547,
  • 所有与 DHCP 相关的多播地址,
  • ICMPv6 邻居发现。

我想用 tcpdump 或 wireshark 捕获与 DHCP 相关的流量以供以后分析。

尽管我想让过滤器尽可能具体以获得一个小的捕获文件,但我不想错过一些重要的数据包,比如用于验证 IP 地址尚未被占用的数据包。

我错过了什么吗?

Mat*_*ner 6

我解决了以下 PCAP 过滤器:

( udp and ( port 67 or port 68 ) )
or arp
or ( icmp and (icmp[icmptype] == 8 or icmp[icmptype] == 0 ) )
or ( udp and ( port 546 or port 547 ) )
or ( icmp6 and ( ip6[40] == 135 or ip6[40] == 136 ) )
or dst net ff02:0:0:0:0:1:ff00::/104
or dst host ff01::1
or dst host ff02::1
or dst host ff02::1:2
or ( icmp6 and ( ip6[40] == 128 or ip6[40] == 129 ) )
Run Code Online (Sandbox Code Playgroud)

前三行捕获 DHCPv4、ARP(重复地址检测)和 PING。

第四行捕获 DHCPv6,第五行到第八行捕获 IPv6 的重复地址检测。第 9 行捕获 DHCPv6 代理的多播,最后一行用于 PING6。

当然,这会捕获许多与 DHCP 流量无关的数据包。这些都需要事后整理。

也许根本不需要 PING 和 PING6 流量。