Can you query a DHCP server using netsh to display the IP address assigned to a MAC?
Hello,
I am working with our Windows 2003 DHCP server at work via netsh and I am trying to optain the IP address of a client using the MAC address. I can run the following command:
C:\Program Files\Common Files\IBM Tivoli>netsh dhcp server scope 10.40.0.0 show clients
and it prints the output
Changed the current scope context to 10.40.0.0 scope.
Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
================================================================================
==
IP Address - Subnet Mask - Unique ID - Lease Expires -T
ype
================================================================================
==
10.40.252.1 - 255.255.0.0 - 00-18-4d-db-ba-5f -7/14/2009 9:33:31 AM -
D
10.40.252.2 - 255.255.0.0 - 00-1a-64-ae-2d-2e -7/14/2009 1:11:35 PM -
D
10.40.252.3 - 255.255.0.0 - 00-1a-64-39-04-ea -7/14/2009 9:27:18 AM -
D
10.40.252.4 - 255.255.0.0 - 00-14-5e-f4-0b-90 -7/14/2009 9:21:44 AM -
D
10.40.252.5 - 255.255.0.0 - 00-14-5e-55-8d-38 -7/14/2009 9:41:21 AM -
D
10.40.252.6 - 255.255.0.0 - 00-1a-64-39-04-e6 -7/14/2009 9:44:27 AM -
D
10.40.252.7 - 255.255.0.0 - 00-0d-60-1c-c9-d3 -7/14/2009 9:44:54 AM -
D
What I would like to do is only display the IP address for the given Unique ID in my script which is a variable containing a MAC address. I have successuflly put the above information into a file by using the > C:\dhcp_dump.txt extension to my command but I do not know how to manipulate the output to only display or dump the single IP address assigned to the Unique ID/MAC listed above. Any suggestions?
Re: Can you query a DHCP server using netsh to display the IP address assigned to a MAC?
djackson88 a écrit :
> Hello,
>
> I am working with our Windows 2003 DHCP server at work via netsh and I
> am trying to optain the IP address of a client using the MAC address. I
> can run the following command:
>
> C:\Program Files\Common Files\IBM Tivoli>netsh dhcp server scope
> 10.40.0.0 show clients
>
> and it prints the output
>
> Changed the current scope context to 10.40.0.0 scope.
>
> Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION
> IP
> ================================================================================
> ==
> IP Address - Subnet Mask - Unique ID - Lease Expires
> -T
> ype
> ================================================================================
> ==
>
> 10.40.252.1 - 255.255.0.0 - 00-18-4d-db-ba-5f -7/14/2009
> 9:33:31 AM -
> D
> 10.40.252.2 - 255.255.0.0 - 00-1a-64-ae-2d-2e -7/14/2009
> 1:11:35 PM -
> D
> 10.40.252.3 - 255.255.0.0 - 00-1a-64-39-04-ea -7/14/2009
> 9:27:18 AM -
> D
> 10.40.252.4 - 255.255.0.0 - 00-14-5e-f4-0b-90 -7/14/2009
> 9:21:44 AM -
> D
> 10.40.252.5 - 255.255.0.0 - 00-14-5e-55-8d-38 -7/14/2009
> 9:41:21 AM -
> D
> 10.40.252.6 - 255.255.0.0 - 00-1a-64-39-04-e6 -7/14/2009
> 9:44:27 AM -
> D
> 10.40.252.7 - 255.255.0.0 - 00-0d-60-1c-c9-d3 -7/14/2009
> 9:44:54 AM -
> D
>
> What I would like to do is only display the IP address for the given
> Unique ID in my script which is a variable containing a MAC address. I
> have successuflly put the above information into a file by using the >
> C:\dhcp_dump.txt extension to my command but I do not know how to
> manipulate the output to only display or dump the single IP address
> assigned to the Unique ID/MAC listed above. Any suggestions?
netsh dhcp server scope 10.40.0.0 show clients | find "00-00-00-00-00"
better
set mac=00-00-00-00-00
netsh dhcp server scope 10.40.0.0 show clients | find "%MAC%"
--
François Dunoyer
Quelques textes qui m'ont séduit : http://fdunoyer.free.fr/textes.htm
Site perso : http://fds.mvps.org
Blog perso : http://fdunoyer.spaces.live.com/
Blog : http://fds34.spaces.live.com/