BPF表达式仅捕获arp-reply数据包 [英] BPF expression to capture only arp-reply packets

查看:408
本文介绍了BPF表达式仅捕获arp-reply数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个 BPF 表达式只能捕获arp-reply数据包?当前,我正在使用Pcap4J和以下BPF表达式:

Is there a BPF expression that would only capture arp-reply packets? Currently, I am using Pcap4J and the following BPF expression:


arp和dst主机 host 和ether dst mac

arp and dst host host and ether dst mac

其中 host 是设备的IP地址,而 mac 是我的主网络接口的MAC地址。不幸的是,当捕获数据包时,此过滤器还允许捕获ARP广播请求,因此我不得不采取额外的步骤来检查ARP标头的操作字段是否为2而不是1。

where host is the IP address of my device and mac is the MAC address of my primary network interface. Unfortunately, when packets are captured, this filter allows ARP broadcast requests to also be captured, so I have to take an extra step to check if the operation field of the ARP header is 2 and not 1.

推荐答案

尝试一下:


(arp [6:2] = 2)以及dst主机host和ether dst mac

(arp[6:2] = 2) and dst host host and ether dst mac

这篇关于BPF表达式仅捕获arp-reply数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆