Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search dhcp server for ip address?

Status
Not open for further replies.

cfont

IS-IT--Management
Dec 12, 2002
15
US
i need a script to search our windows 2000 dhcp server for an ip address. for instance, if given an IP address i want to return the mac address. anyone have a way to do that?

i have dhcpcmd and dhcpobjects that i'm looking into as possibilities but i'm not familiar with those enough to do anything yet.

along with this i'd like to know if i can query the dns server possibly as well.
 
Hello cfont,

Not sure if up to answering your question because I think there might be something more tricky hidden for you to ask.

But, if I understand your question correctly, given you know a particular "ipaddress" in your network, you want to find the mac address...

If that is the case, you can do this by wmi scripting. [1] Connect to the m/c with its ip address; [2] query its win32_networkadapterconfiguration with ipenabled=true; [3] look at its returned collection with the object with it ipaddress array containing the ipaddess that you use it to connect to; [4] after identifying the object, read its macaddress property.

This is the plot for this script which is not complicated.

regards - tsuji
 
Further notes:

This is what I have in mind.
Code:
snode="123.102.34.156"    '<<<your input here

set svc=getobject("winmgmts:\\"&snode&"\root\cimv2")
sQuery="select * from win32_networkadapterconfiguration where ipenabled=true"
bFound=false : smacaddr=""
for each onic in svc.execquery(sQuery)
    for each sipaddr in onic.ipaddress
        if snode=sipaddr then bFound=true : exit for
    next
    if bFound then smacaddr=onic.macaddress : exit for
next
set svc=nothing
wscript.echo "ip address = " & snode & vbcrlf & "mac address = " smacaddr
- tsuji
 
hello tsuji,

thanks for the suggestion and i'm definately adding this to my script bank but its not going to do exactly what i need.

the problem is that some machines i'm looking for may not be turned on when i need to find them. i work on a university campus and we're often trying to find a machine's mac address so the network guys can block (or otherwise disengage) the network permissions for a given machine because of misconduct (virus, spam, etc.). generally, they will all have picked up an address from one of my dhcp servers so i'd like to search that for the info.

however, i am definately adding your idea to what i can do now if the machine is on. thanks again.

-cfont
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top