Discussion Locked

Interrogate Win2k DHCP via script

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'm working on a retail network consisting of some 800 shops. There are about 6 win2k prof clients in each shop. What I want to do is use wake on lan to bring up any machine on the network that has been switched off (as shop staff are prone to do when they go home). The wake on lan works fine, but what I need is a way of getting the mac addresses for each client from DHCP. Currently, we use getmac from the reskit and have built up a DB of mac addresses, but if I could get that info live from DHCP then there would be no problems with network cards being swapped, or new machines added that have not yet been 'getmac'ed etc. Note- all I'm interested in is how to get the macs from DHCP, no workarounds please ! Any ideas how to do this ?? a cool2000 points to whoever provides the answer.

5 replies

by adrian.wilkins

Well, open DHCP goto the scope for your network, clk on address leases and look at the unquie id, this is the mac address.

by beermonster

Thanks, but 800 shops, times approx 6 workstations, equals around 4800 mac addresses - which is why I want to automate it. Ideally I'll use an LDAP query to get a list of machines, and query DHCP using that list.

by steved

I don't know of and can't find any reference to a scripting interface for the DHCP server. However, it does keep logs of all important events, including new leases and lease renewals. The logs are found in the \Winnt\System32\dhcp folder with file names like DhcpSrvLog.Mon, DhcpSrvLog.Tue, etc. (This is in NT 4.0. I imagine Win 2K is about the same.) It should be very easy to parse these logs and get the info you need. They are comma-delimited, where each line contains the following fields:

ID,Date,Time,Description,IP Address,Host Name,MAC Address

The ID is interpreted as:

00 The log was started.
01 The log was stopped.
02 The log was temporarily paused due to low disk space.
10 A new IP address was leased to a client.
11 A lease was renewed by a client.
12 A lease was released by a client.
13 An IP address was found to be in use on the network.
14 A lease request could not be satisfied because the scope's address pool was exhausted.
15 A lease was denied.
20 A BOOTP address was leased to a client.

I hope this helps.

Steve Diamond

This discussion is closed to new replies.