Search code examples
network-programmingmac-addressdhcparp

Find MAC address through direct ethernet connection


I want to find the MAC address of a device. Example: Plug a network cable from my linux mashine to the target device, send some command, receive MAC.

The best solution I have now is to connect a router to the device, wait for it to give out a dhcp lease, connect to the router via ssh and read out the lease table.

I understand that dhcp servers wait for a request from the device and then give out a lease but I would like to actively send some request to the device and get the MAC from the answer directly.

The biggest problem seems to be that without running a dhcp server I can't communicate with the device. Can this be done through a lower layer? Maybe an ARP request?

Thanks!


Solution

  • We solved this by listening for packets from the target mashine and extracting the mac address from the first packet we get.

    Thanks for all the answers though!