Solved

Remote MAC Address Using IP Address

Posted on 2013-11-28
6
453 Views
Last Modified: 2013-12-06
Hi
I am developing a console app that will run from the command line on a Windows 2008 R2 64 bit server.  Using C++, what is the most reliable method of acquiring the MAC address of a remote Microsoft Windows machine using its IP address?
Thanks
0
Comment
Question by:antonms
  • 3
  • 2
6 Comments
 
LVL 2

Assisted Solution

by:weifai
weifai earned 167 total points
ID: 39684014
Have a look at the SendARP function: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366358%28v=vs.85%29.aspx

It makes an ARP request and returns a MAC address in its OUT parmeters.
0
 
LVL 46

Assisted Solution

by:Craig Beck
Craig Beck earned 333 total points
ID: 39686780
ARP is a good idea, but won't help if the remote PC is on a different VLAN or on a distant network across the internet for example.

ARP uses a broadcast on the same network segment.  If the IP address is on a different subnet the client wouldn't initiate an ARP request for that device's MAC address - instead it would send the request to the default gateway.
0
 

Author Comment

by:antonms
ID: 39688523
Hi - thank you both for your replies - SendARP looks to be the solution. However I was wondering how well SendARP would work if the PC was a virtual PC and/or if there was more than one MAC address at the IP address?
Thanks
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 46

Accepted Solution

by:
Craig Beck earned 333 total points
ID: 39689569
A virtual PC will be assigned a virtual MAC address, which will respond to the ARP request.

An IP address can't be used by more than one MAC address at a time, so you'll only ever see the MAC of the device that's actually using the IP at the time.
0
 

Author Closing Comment

by:antonms
ID: 39701853
Thanks. After much testing SendARP() proved to be a reliable solution across all MS Windows platforms.
0
 
LVL 46

Expert Comment

by:Craig Beck
ID: 39701987
Cheers, but you should mark the answer by: weifaiPosted on 2013-11-28 at 18:25:15ID: 39684014 as the answer.

:-)
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question