How to use the Netsh utility to export and import DHCP scopes
IMPORTANT: This article contains information about editing the registry.
Before you edit the registry, make sure you understand how to restore it if
a problem occurs. For information about how to do this, view the "Restoring
the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help
topic in Regedt32.exe.
SUMMARY
WARNING: Using Registry Editor incorrectly can cause serious problems that may
require you to reinstall your operating system. Microsoft cannot guarantee that
problems resulting from the incorrect use of Registry Editor can be solved. Use
Registry Editor at your own risk.
For information about how to edit the registry, view the "Changing Keys and
Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete
Information in the Registry" and "Edit Registry Data" Help topics in
Regedt32.exe. Note that you should back up the registry before you edit it. If
you are running Windows NT or Windows 2000, you should also update your
Emergency Repair Disk (ERD).
Microsoft Windows Server provides administration utilities for Dynamic Host
Configuration Protocol (DHCP) you can use to manage DHCP servers. DHCP Manager
(Dhcpadmn.exe) is provided in Windows NT 4.0, while the DHCP Snap-in is provided
as part of the MMC in Windows 2000/2003. Neither utility permits you to move a DHCP
database from one server to another server. This article explains how to move a
database from a server to another server.
Note that there are two sections to this article, and each section should be
treated independently. Use only the section that corresponds to the type of
migration you want to do.
IMPORTANT: It is strongly recommended that you perform the migration by using
Regedt32 as detailed in the following article in the Microsoft Knowledge Base:
Q130642 How to Move a DHCP Database to Another Windows Server
WARNING: This document is provided only for use where a migration using the steps
in the preceding article is not possible and scripting is the only way of
performing the migration.
IMPORTANT: Moving a DHCP Database incorrectly can leave your computer in an
unstable state. Because of this, it is strongly recommended that before you try
to perform a database migration you should:
- Create a backup of your working configuration.
- Test these procedures in a lab environment.
- Perform all of the following steps exactly.
Also, it is assumed the destination server does not have the DHCP Server service
installed. If the DHCP Server service has been installed it must be removed. To
do so:
1. Click Start, point to Settings, click Control Panel, and then double-click
Add/Remove Programs.
2. Click Add/Remove Windows Components, double-click Networking Services (the
words, not the check box), and then click to clear the DHCP Server check box.
After you have installed the DHCP Server service on the destination server, it is
important that you do not start the DHCP MMC until you are instructed to do so.
The first time you start the MMC, it checks for and creates certain settings
that should only be created at the end of the procedures listed below.
NOTE: It is possible that on the source server the DHCP database name and
location have been changed from the default of
%systemroot%system32dhcpdhcp.mdb. This migration procedure is not affected by
differences in database location between source and destination servers, and
will require the destination DHCP server to use the default name and path
settings of %systemroot%system32dhcpdhcp.mdb.
Also, several of the following steps state that commands such as "net stop
dhcpserver" (without the quotation marks) should be run. You should run these
commands at a command prompt.
From the Source DHCP Server:
1. Dump the configuration of the Windows based DHCP server:
dump the configuration from a Windows Server based computer. Also, the Windows
NT 4.0-based DHCP server must be running Windows NT 4.0 Service Pack 2 or
higher. On any Windows 2000-based server running DHCP, type "netsh dhcp
server <IP address> dump > c:export.txt" (without the quotation
marks) at a command prompt, and then press ENTER, where <IP address> is
the IP address of the Windows NT 4.0-based DHCP server.
2. To prevent DHCP from starting after the database has been transferred,
disable the DHCP Server service by using the Services tool in Control Panel:
a. Click Start, point to Settings, click Control Panel, and then double-click
Services.
b. In the Services box, click Microsoft DHCP Server, click Startup, and then
click Disabled under Startup Type.
3. Stop the DHCP Server service by using the "net stop dhcpserver" (without the
quotation marks) command at a command prompt.
From the Destination DHCP Server:
1. Install the DHCP server service:
a. Click Start, point to Settings, click Control Panel, and then double-click
Add/Remove Programs.
b. Click Add/Remove Windows Components, double-click Networking Services (the
words, not the check box), and then click to select the Dynamic Host
Configuration Protocol (DHCP) check box.
2. Remove the Option definitions from the destination DHCP server by using
Registry Editor to delete the following registry key:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftDhcpServerConfigurationOptionInfo
3. Copy the Export.txt file to the destination server, and then rename the file
to C:Import.txt.
4. Edit the Import.txt file with Notepad.exe and replace the IP address of the
source DHCP server with the IP address of the destination DHCP server.
Perform a Replace on the string "SERVER <x.x.x.x>" with "SERVER
<y.y.y.y>", where <x.x.x.x> is the source DHCP server address and
<y.y.y.y> is the destination DHCP server address.
IMPORTANT: Do not just string replace the "x.x.x.x" with "y.y.y.y" as either
address may be used in option values within a scope. Save your changes.
5. If the DHCP database name or path on the source server is different than the
database name or path on the destination server, you must edit the Import.txt
file and correct the values for any or all of the following settings:
AuditLog, DatabaseBackupPath, DatabaseName, and DatabasePath. Note that the
default path is typically c:winntsystem32dhcpDhcp.mdb. Save your changes.
6. Load the Import.txt file into the destination DHCP server with the "netsh
exec c:import.txt" (without the quotation marks) command.
7. Stop the DHCP Server service on the destination server with the "net stop
dhcpserver" (without the quotation marks) command.
8. Delete all of the contents of the %systemroot%system32dhcp folder,
including its subfolders.
9. Copy the DHCP database file (Dhcp.mdb) in the %systemroot%system32dhcp
folder on the source server to the %systemroot%system32dhcp folder on the
destination server.
10. Start the DHCP Server service with the "net start dhcpserver" (without the
quotation marks) command.
IMPORTANT: You should receive the following error message:
System error 20036 has occurred. The system cannot find message text for
message number 0x4e44 in the message file for BASE.
Receiving this error message is normal, please proceed to the next step.
11. If you also receive the following error message, copy the Edb500.dl_ file
from the Windows 2000 CD-ROM, expand it to the System32 folder, repeat step
8, and when you no longer receive this error message, continue to the next
step.
NOTE: This also corresponds with an EventID 1008 in the Application log.
12. View the Application Log in the Event Viewer. If the JetConv application
logs EventID 1000, the database has been converted successfully.
13. Start the DHCP Server snap-in from the Administrative Tools group.
14. Click the destination DHCP server, and then click Reconcile All Scopes on
the Action menu. Click Verify. If any leases need to be reconciled, click
Reconcile to synchronize the registry and database.
15. If the Windows 2000-based server is part of an Active Directory domain, the
server must be Authorized.
To move a DHCP database from a Windows 2000/2003 Server to a Windows 2000/2003 Server:
IMPORTANT: Moving a DHCP Database incorrectly can leave your computer in an
unstable state. Because of this, it is strongly recommended that before you try
to perform a database migration you should:
- Create a backup of your working configuration.
- Test these procedures in a lab environment.
- Perform all of the following steps exactly.
Also, it is assumed the destination server does not have the DHCP Server service
installed. If the DHCP Server service has been installed it must be removed
first. To do so:
1. Click Start, point to Settings, click Control Panel, and then double-click
Add/Remove Programs.
2. Click Add/Remove Windows Components, double-click Networking Services (the
words, not the check box), and then click to clear the DHCP Server check box.
After you have installed the DHCP Server service on the destination server, it is
important that you do not start the DHCP MMC until you are instructed to do so.
The first time you start the MMC, it checks for and creates certain settings
that should only be created at the end of the procedures listed below.
NOTE: It is possible that on the source server the DHCP database name and
location have been changed from the default of
%systemroot%system32dhcpdhcp.mdb. This migration procedure is not affected by
differences in database location between source and destination servers, and
will require the destination DHCP server to use the default name and path
settings of %systemroot%system32dhcpdhcp.mdb.
Also, several of the following steps state that commands such as "net stop
dhcpserver" (without the quotation marks) should be run. You should run these
commands at a command prompt.
From the Source DHCP Server:
1. Dump the configuration of the source DHCP server by using the "netsh dhcp
server <x.x.x.x> dump >c:export.txt" (without the quotation marks)
command from any Windows 2000-based DHCP Server, where <x.x.x.x> is the
IP address of the source DHCP server.
2. To prevent DHCP from starting after the database has been transferred,
disable the DHCP Server service:
a. Click Start, point to Programs, point to Administrative Tools, and then
click Computer Management.
b. Double-click "Services and Applications", click Services, right-click the
DHCP server on the Services list, and then click Properties.
c. Change the "Startup type" to Disabled, and then click OK.
3. Stop the DHCP Server service by using the "net stop dhcpserver" (without the
quotation marks) command at a command prompt.
From the Destination DHCP Server:
1. Install the DHCP Server service:
a. Click Start, point to Settings, click Control Panel, and then double-click
Add/Remove Programs.
b. Click Add/Remove Windows Components, double-click Networking Services (the
words, not the check box), and then click to select the Dynamic Host
Configuration Protocol (DHCP) check box.
2. Clear the Option definitions off of the destination DHCP server by deleting
the following registry key:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftDhcpServerConfigurationOptionInfo
3. Copy the Export.txt file to the destination server, and then rename the file
to c:Import.txt.
4. Edit the Import.txt file with Notepad.exe and replace the IP address of the
source DHCP server with the IP address of the destination DHCP server.
Perform a Replace on the string "SERVER <x.x.x.x>" with "SERVER
<y.y.y.y>", where <x.x.x.x> is the source DHCP server address and
<y.y.y.y> is the destination DHCP server address.
IMPORTANT: Do not just string replace the "x.x.x.x" with "y.y.y.y" as either
address may be used in option values within a scope. Save your changes.
5. If the DHCP database name or path on the Source server is different than the
database name or path on the destination server, you must edit the Import.txt
file to correct the values for any or all of the following settings:
AuditLog, DatabaseBackupPath, DatabaseName, and DatabasePath. Note that the
default path is typically c:winntsystem32dhcpDhcp.mdb. Save your changes.
6. Load the Import.txt file into the destination DHCP server by using the "netsh
exec c:Import.txt" (without the quotation marks) command.
7. Stop the DHCP Server service by using the "net stop dhcpserver" (without the
quotation marks) command.
8. Delete all of the contents of the %systemroot%system32dhcp folder,
including subfolders.
9. Copy the DHCP database file (Dhcp.mdb) in the %systemroot%system32dhcp
folder on the source server to the %systemroot%system32dhcp folder on the
destination server.
10. Start the DHCP Server service with the "net start dhcpserver" (without the
quotation marks) command.
11. Start the DHCP Server snap-in from the Administrative Tools group. Click the
destination DHCP server, and then click Reconcile All Scopes on the Action
menu. Click Verify. If any leases need to be reconciled, click Reconcile to
synchronize the registry and database.
12. If the Windows 2000-based server is part of an Active Directory domain, the
server must be Authorized.
