Search code examples
c#network-programmingipv6arp

Get a remote MAC address via IPv6


Is it possible to get the MAC from an another PC in the same Network via IPv6 (without WMI)? With IPv4 it is easy (ARP).

IPv6 uses the "Neighbor Discovery Protocol" (NDP) to get the MAC address. Are there any methods in .Net for this?


Solution

  • You can run the external command "netsh int ipv6 show neigh", and filter out the host you are interested in. You should have contacted it just before that, so you know it is in the NC.

    If you want an API for that, use GetIpNetTable2 or, more directly, ResolveIpNetEntry2. I doubt there is a .NET API for this, so you'll have to use PInvoke.