-1

Can some one tell me, how to get remote host MAC address by using its ip address in linux by using c programming(could be netlink sockets or BSD sockets)?

linuxman
  • 83
  • 3
  • 10
  • 1
    possible duplicate of [Getting the MAC address of the remote host](http://stackoverflow.com/questions/1092463/getting-the-mac-address-of-the-remote-host) – holgac Apr 21 '15 at 11:41
  • 1
    The question above is for c#, but you can't do it anyway (without sending actual ARP or NDisc requests), so it's related. – holgac Apr 21 '15 at 11:42
  • 2
    You can get only MAC addresses of computers on your local network. – Marian Apr 21 '15 at 11:46
  • The local network MACs are listed in `/proc/net/arp` – Alexis Wilke Apr 02 '18 at 21:04

1 Answers1

0

This can't be done using C programming. If it was possible then there wouldn't be any protocol like ARP to get the link layer address.

You can implement ARP request and reply using socket programming. But that's not what you want in this case I think. Anyway in that case you can refer to this discussion link.

You can have a look at this for that purpose source code.

Community
  • 1
  • 1
user2736738
  • 30,591
  • 5
  • 42
  • 56