BPF expression to capture only arp-reply packets

孤人 提交于 2019-12-11 02:05:11

问题


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

arp and dst host host and ether dst mac

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.


回答1:


Try this:

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



来源:https://stackoverflow.com/questions/40196549/bpf-expression-to-capture-only-arp-reply-packets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!