Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

From my computer, I want to query my DHCP server to find a specific mac adress. I want to enter the hostname to search, and getting back the Mac address.

Something like :

netsh dhcp server scope show clients |find hostname

This command line doesn't works, but maybe you have some tips ?

Thank you,

share|improve this question
2  
If you remove the |find hostname, what error messages do you receive? I can see two issues: 1.) You're not specifying the dhcp server name/IP, netsh dhcp server \\servername... 2.) You're not specifying which scope you want: netsh dhcp server \\servername scope 10.130.40.0 show clients. –  jscott Apr 12 '12 at 12:50
add comment

2 Answers

up vote 0 down vote accepted

If you are comfortable with Powershell, this script will help you find what you need: https://sites.google.com/site/assafmiron/ServerScripts/get-dhcpleases

This script almost works as well. It currently lists extra clients. Some regex magic with the find command parameters could fix this. Save to to a .cmd file and specify your dhcppserver and a valid scope.

for /f "skip=4 delims=: tokens=2" %%a in ('nslookup %1') do set IP=%%a
netsh dhcp server \\ourdhcpsvr scope 192.168.1.0 show clients|findstr "%IP%"
share|improve this answer
add comment

With "netsh dhcp server \servername scope 10.130.40.0 show clients" you get a list without client names, when you add "1" at the end of this line, you get the client names as well:

"netsh dhcp server \servername scope 10.130.40.0 show clients 1"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.