6

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.

rolling_codes
  • 15,174
  • 22
  • 76
  • 112

1 Answers1

7

Try this:

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

kaitoy
  • 1,545
  • 9
  • 16
  • You my friend, are a genius. Can you explain what the `6:2` index is doing? – rolling_codes Oct 23 '16 at 17:09
  • 4
    The 6 is the offset in ARP header, where the operation field starts. The 2 is the field's length. arp[6:2] returns the operation field's value. – kaitoy Oct 23 '16 at 23:18