This article will provide the information on How to migrate an existing DHCP server to another DHCP server.
Using NETSH command
- Log in to the DHCP server that you want to migrate and open Command Prompt with elevated permission.
- Run the following command on the Command Prompt.
netsh dhcp server export c:\dhcp.txt all
You can change the path and the filename.
- You should see confirmation after a short bit. The amount of time to backup your database will be dependent upon the size of the data that will be migrated.
- On the target server, make sure the DHCP role has been installed. To migrate the exported file, open Command Prompt with elevated command and run the command below:
netsh dhcp server import c:\dhcp.txt all
- Sometimes, you will get the following error:
“Error while importing option “6.” “This option conflicts with the existing option “” An Internal Error Occurred.”
You need to remove the following entries in Server Options before running the import command.
- 006 DNS Server
- 015 DNS Domain Name
Using Export-DhcpServer CmdLet
For Windows Server 2012 and above, there is a PowerShell command that can be used to migrate the DHCP server entries. You can run the command below to back up the current from the old DHCP server, let say the name of the old server is win2k8r2-dhcp.msnoob.com:
Export-DhcpServer –ComputerName win2k8r2-dhcp.msnoob.com -Leases -File C:exportdhcpexp.xml -verbose
In case one doesn’t wish to export lease information, leave out the –Leases switch from the command.
To export the XML file, you can run the command below:
Import-DhcpServer –ComputerName DHCP1.msnoob.com -Leases –File C:exportdhcpexp.xml -BackupPath C:dhcpbackup -Verbose
If you want to migrate specific scopes (e.g. 10.1.1.0, 10.1.2.0) to the Windows Server 2012 DHCP server instead of migrating all the scopes, you can use the following import command:
Import-DhcpServer –ComputerName DHCP1.msnoob.com -Leases –File C:exportdhcpexp.xml -BackupPath C:dhcpbackup -Verbose –ScopeId 10.1.1.0, 10.1.2.0
If the DHCP server replication is set up between two or more DHCP servers, the command above should be running on the primary DHCP server.