Windows Server TechGuides
Scripting out DHCP reservations
By Rick Vanover , Special to ZDNet Asia
Tuesday, August 05, 2008 02:15 PM
Find out how the Netsh tool in Windows Server 2008 can save a lot of time during a large scope modification or creation.
Netsh is one of the most powerful Windows networking tools in the pre-PowerShell era. For Windows Server 2008, Netsh adds new contexts and expands some of the existing functionality introduced in Windows 2000.
One use of Netsh includes some management of DHCP scopes to modify reservations. An area in which this can be very useful is to script out a large batch of reservations for a number of virtual machines for a server subnet or a test scenario.
On a Windows Server 2008 system running DHCP, this is the scripted out command to make or modify a reservation:
netsh dhcp server dc1 scope 192.168.1.0 add
reservedip
192.168.1.189 080027C591F9 XVM1.WS2K8.DEV
In this example, the DHCP server name and scope are populated, as well as the desired IP address, the MAC address, and the DNS domain name of the system for the reservation. Once the command is entered, Netsh interacts with the DHCP service on the server to make the appropriate reservation to the scope. Figure A shows the command entered successfully.
Figure A
Figure A
If an existing reservation needs modification, the existing entry should be sent a sequence of commands that delete the existing reservation and then add the new one. Here's an example:
netsh dhcp server dc1 scope 192.168.1.0 delete reservedip
192.168.1.189 080027C591F9
netsh dhcp server dc1 scope 192.168.1.0 add reservedip
192.168.1.181 080027C591F9
Netsh finesse can enable many tasks to be completed quickly. Plus, being able to modify many DHCP reservations in a scriptable fashion can save a lot of time during a large scope modification or creation.
About Me
- CSphere
- My Name is Indra Born in Banjar Baru, South Kalimantan I live in Bandung, Indonesia