I need to get the mapping of MAC to IP stored on DHCP server, either through a program running on the server itself or preferably through a program running on one of the DHCP clients.
I understand netsh utility can be used to get the dump however i have not had much success with that.
Any working examples or hint on that?
I have admin rights on DHCP server
Edit
I dont want to use arp cache as that would require me to either broadcast ping (which is not allowed on windows) or ping the all possible ip address of subnet( which takes lot of time).
I am sure that DHCP server stores the mapping of MAC to IP, how can i use that information, to map MAC to IP address?
You can use the DHCP Objects component from the Windows 2000 Resource Kit for this. Even though the component is hard to find, is made for Windows 2000, goes out of life support in July 2010 according to Microsoft and has very little documentation, it does work.
DHCPOBJS.DLL
file with regsvr32
or create a COM+ Application for it. Which is applicable depends on how the COM component is going to be used on your system.tlbimp.exe
to create a managed wrapper around DHCPOBJS.DLL
now that it's registered by the system.DhcpObjects.dll
.Now you can write code like this against the component:
using DhcpObjects;
class Program {
static void Main(string[] args) {
var manager = new Manager();
var server = dhcpmgr.Servers.Connect("1.2.3.4");
// query server here
}
}
The installer also provides a Windows Help File which contains further documentation on how to query and manipulate a DHCP server. The section "The Object Model" is quite helpful.