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.
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.
For more about Netsh, check out my post: Creating port policies in Windows Server 2008 with Netsh.
Stay on top of the latest Windows Server 2003 and Windows Server 2008 tips and tricks with our free Windows Server newsletter, delivered each Wednesday. Automatically sign up today!