简体   繁体   中英

How to receive a packet UDP with a known destination MAC different to that of the listening interface

I am trying to listen for a specific discovery packet that will be sent over UDP destined for a known MAC address. This MAC address will not be the same as the MAC address of the interface I am receiving on.

I have tried Beej's UDP listener but it only receives packets with the correct MAC.

When I listen with tcpdump I can see the packets are making it to the device.

It looks like I could receive on a raw socket (although haven't got that working yet) but would there be a way to filter only the destination MAC I want?

Can anyone give me any guidance with this?

Your interface does not normally receive packets that are not sent to its own address. It just ignores them.

You need to set your network interface in promiscuous mode and use a packet capture interface provided by Linux.

Have a look at libpcap , the manual page is here .

This is the same mechanism that tcpdump uses. It is a library which provides an interface and a filter to the packet capture mechanism in the kernel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM