14.16. Importing and Exporting DHCP Server Configuration

Problem

You want to export the DHCP Server configuration and use it on another server.

Solution

Using a graphical user interface

The Windows 2000 Resource Kit contains a tool called dhcpexim , which is a simple GUI for exporting and importing DHCP Server configuration. However, I've tested it on Windows Server 2003 and have not been able to make it work properly. Based on other newsgroup postings on the subject, it doesn't appear the Windows 2000 version of dhcpexim works with Windows Server 2003. So until a new version is released (which may never happen), your only option on Windows Server 2003 is the CLI solution described next.

Using a command-line interface

The following command exports DHCP Server configuration to c:\dhcp.txt:

>  netsh dhcp server export C:\dhcp.txt all

To import this configuration on another server, copy c:\dhcp.txt to the target server and run the following command on that server (I'm assuming the DHCP Server has already been installed):

>  netsh dhcp server import C:\dhcp.txt all

Using VBScript

See Recipe 14.0 for more information on how to run the netsh command from within a script.

Discussion

The netsh tool makes it easy to import and export DHCP Server configuration information. In the CLI solution, I showed how to export all scope information, but you can specify a subset if you want only certain ones. The following command exports only the scopes pertaining to 10.1.2.0 and 10.1.3.0:

> netsh dhcp server ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.