Finding MAC Address

F

FR3AK

Hi.

does anyone have any idea of how to find the mac address of a remote
networking device? I've worked with WMI and it works fine as long as the
target machine is a Windows computer, however, i want to return the MAC
address of ANY IP device on my network.

right now, i have a totally inefficient way to return a mac address, but
it's only by dropping to a command prompt and executing the ARP command (all
within code....it's not as ugly as it sounds).

executing ARP within a loop (range of IP's to scan) is not a practical
solution. Has anyone had success in finding info on how to do this?

thank you for your assistance.
 
N

Nicholas Paldino [.NET/C# MVP]

Rick,

You can make a call to the GetIpNetTable function in the IP Helper API.
It will allow you to get the IP to MAC-address mapping table. You can also
call the SendARP function to make a request for the MAC address for a
particular IP address.

Hope this helps.
 
F

FR3AK

Thanks for your help.

I believe the SendARP only works on win2k machines and above, so i'll try
the GetIpNetTable function as you mentioned. :)

The code i have is working, but it's taking about 2 minutes to query an
entire subnet....i'm sure there's a better way to do this.

Thanks again for your response.
--
Rick King
(e-mail address removed)

"To the Glory of God, The Father"

Nicholas Paldino said:
Rick,

You can make a call to the GetIpNetTable function in the IP Helper API.
It will allow you to get the IP to MAC-address mapping table. You can also
call the SendARP function to make a request for the MAC address for a
particular IP address.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

FR3AK said:
Hi.

does anyone have any idea of how to find the mac address of a remote
networking device? I've worked with WMI and it works fine as long as the
target machine is a Windows computer, however, i want to return the MAC
address of ANY IP device on my network.

right now, i have a totally inefficient way to return a mac address, but
it's only by dropping to a command prompt and executing the ARP command (all
within code....it's not as ugly as it sounds).

executing ARP within a loop (range of IP's to scan) is not a practical
solution. Has anyone had success in finding info on how to do this?

thank you for your assistance.
--
Rick King
(e-mail address removed)

"To the Glory of God, The Father"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top