BPF expression to capture only arp-reply packets

2.7k Views Asked by At

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

There are 1 best solutions below

2
On BEST ANSWER

Try this:

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