Search code examples
c#windowsnetwork-programmingip-addressmac-address

Easiest way to get MAC address from a (non-local) IP address in IPv4


Is there an easy way to get a MAC address of a machine connected to my app via a TCP/IPv4 socket?

Or in more general terms:

If I have the IP address, what is the best way to get the corresponding MAC address in IPv4?


Solution

  • It is the ARP table's job to keep that information. The best thing to do would be to read it out of there.

    You might consider reading the answers to Query ARP cache to get MAC ID. The questioner was using Java, but otherwise its your identical question.