开发者

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

开发者 https://www.devze.com 2023-04-01 02:48 出处:网络
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 receiv

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 any开发者_如何转开发one 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消