Getting DHCP client names for non-Windows gear

Answered Getting DHCP client names for non-Windows gear

  • Friday, August 17, 2012 12:15 AM
     
     
    Just trying (via a command line call on my Win7 Pro PC) to resolve IP addresses to names for non-Windows clients on the network that have been assigned names on a DHCP server on a Windows 2003R2 box. It's easy enough for Windows clients; ping -a IPaddress, but for non-Windows clients that doesn't work. I've looked (and tried) most of the netsh dhcp calls I can find, but nothing seems to pop out. Any suggestions?

All Replies

  • Friday, August 17, 2012 1:53 AM
     
     

    Might try

    nbtstat -a xxx.xxx.xxx.xxx

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Friday, August 17, 2012 2:07 AM
     
     
    Sorry, meant to say I tried that and it didn't work.
  • Friday, August 17, 2012 2:09 AM
     
     
    Should be nbtstat -A IPaddress, but still doesn't work. . .
  • Monday, August 20, 2012 6:00 AM
    Moderator
     
     Answered

    Hi,

    Thank you for the post.

    I understand you want to find the DHCP client device name which show none Name in DHCP console--address lease.
    To find the device name, you could find the their name by MAC address in switches MAC tables.
    To security your DHCP service, you could set 802.1x on switches ports or set up DHCP with MAC address filtering.
    http://technet.microsoft.com/en-us/library/dd759190.aspx
    http://blogs.technet.com/b/teamdhcp/archive/2007/10/03/dhcp-server-callout-dll-for-mac-address-based-filtering.aspx

    If there are more inquiries on this issue, please feel free to let us know.

    Regards


    Rick Tan

    TechNet Community Support

  • Monday, August 20, 2012 9:37 AM
     
     
    The names show up in the DHCP GUI client, but not when you make any command-line calls that I know of. Is there any way I can find out these names using a command-line client?
  • Tuesday, August 21, 2012 2:06 AM
    Moderator
     
     

    Hi,

    As you have already known the hostname, why you need to know it by command line?
    NetBios/WINS (nbtstat) and DNS (nslookup) name resolution should not work in your scenario.
    Anyway, you could add them into local host file and run "ping -a IPaddress" to resolve the hostname.

    Regards


    Rick Tan

    TechNet Community Support

  • Wednesday, October 24, 2012 3:26 PM
     
     Answered Has Code

    Hello,

    I was looking for the same type of information.

    I started from  DhcpReservStats.vbs found in http://gallery.technet.microsoft.com/scriptcenter/a3c9ad7b-6b5c-40ef-a928-3565432735ee and

    changed "show clients" to  "show clients 1" to have device names and not only IP and Mac addresses and

    commenting out "If InStr(strTemp, "-R") Then" to have all DHCP entries and not only reservations.

    Finally, here is my vbscript (getAllDHCPinfo.vbs) :

    strDHCPServer = "your dhcp server or empty string if you run the script on dhcp server"
    
    Set objRegExp=New RegExp
    objRegExp.Global=True
    objRegExp.Pattern= "= (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.\r\n"
    
    Set objShell = CreateObject("WScript.Shell")
    
    ' Get result from "netsh dhcp server show mibinfo" to get all subnets
    Set objQuerySession = objShell.Exec("netsh dhcp server " & strDHCPServer & " show mibinfo")
    strOutput = objQuerySession.StdOut.ReadAll
    Set o=objRegExp.Execute(strOutput)
    
    ' For all scopes
    For i=0 To o.Count-1
      sMsg = sMsg & vbcrlf & o(i).SubMatches(0) & ": " & vbcrlf
      Set oScriptExec = objShell.Exec("netsh dhcp server " & strDHCPServer & " scope " & o(i).SubMatches(0) & " show clients 1")
    
      ' For all DHCP scope clients
      Do Until oScriptExec.StdOut.AtEndOfStream
        strTemp = oScriptExec.StdOut.ReadLine
        sMsg = sMsg & strTemp & vbcrlf
      Loop
    
    Next
    
    ' Show message. If the list is too long, you can send the output to a file
    WScript.Echo sMsg

    You can then run a

    cscript //nologo getAllDHCPinfo.vbs | find /I <devicename or IP you're looking for>


    For a first try, you may try directly on a scope where you know you have such non-Windows devices :

    netsh dhcp server  scope <your scope> show clients 1 | find /I <devicename or Ip you're looking for>

    Regards


    • Edited by Maman Sylvie Wednesday, October 24, 2012 4:17 PM
    • Marked As Answer by OwenWatson Thursday, October 25, 2012 4:40 AM
    •