Migrating the DHCP service from the old server to the new Windows Server 2016 with saving of all the settings of the old server is quite easy. If the old DHCP server is running Windows Server 2008?R2 or Windows Server 2012?R2, you can directly transfer DHCP settings, zones and reservations.
First of all, you need to install the DHCP Server role on a new server which is running Windows Server 2016. You can install the DHCP Server role using the Server Manager console, where you need to run the Add Roles Wizard in the Manage -> Add Roles and Features menu and select the DHCP Server.
But it’s much easier to install the role and role management tools from RSAT (DHCP console and PowerShell module for working with DHCP) using PoSh.
Start the PowerShell console as Administrator and run the following command:
Add-WindowsFeature -IncludeManagementTools DHCP
The -IncludeManagementTools parameter must be specified to install the DHCP server management console. By default, Add-WindowsFeature installs the DHCP server role without the appropriate console.
Next you need to create local DHCP security groups (DHCP Administrators and DHCP Users):
To enable DHCP security settings associated with the local security groups created, restart the DHCP Server service:
Authorize the new DHCP server in the Active Directory domain:
Add-DhcpServerInDC? host1.contoso.com? 192.168.10.35
However, after the DHCP role is installed and the post-installation settings with PowerShell are performed, a connection to this server in the Server Manager console will result in a warning that a post-installation setup is required, even though it has actually already been executed. In this case, even the restart of the server will not help to make this warning disappear.
To remove this status, let’s modify the registry key to a value indicating that the actual DHCP Server role has already been configured using PowerShell:
Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 –Name ConfigurationState –Value 2
In Windows Server 2012 a special PowerShell cmdlets have been added, allowing you to import?export any DHCP server settings. Note that Microsoft simplified the procedure as much as possible, and we will need to execute only two PowerShell commands: Export-DhcpServer and Import-Dhcpserver, which can work remotely. All commands can be executed on one machine (the one to which the server migrates).
Create the folder c:\dhcp (new-item c:\dhcp -type directory) and run the command to export the configuration of the old DHCP server to the XML file named OldDHCPConf.xml.
Export-DhcpServer -ComputerName “oldDhcp.contoso.com” -Leases -File “C:\DHCP\OldDHCPConf.xml” –Verbose
Now you can perform a full import of the DHCP configuration on the new server:
Import-DhcpServer -Leases –File “C:\DHCP\OldDHCPConf.xml” -BackupPath “C:\DHCP\Backup\” –Verbose
Everything is ready. Open the DHCP console and check that all the DHCP scopes, reservations and IP leases are in place.
In the event that you created a failover DHCP configuration uses DHCP Failover, the second server only needs to import the DHCP server configuration:
Import-DhcpServer -Leases –File “C:\DHCP\OldDHCPConf.xml” -ServerConfigOnly? -BackupPath “C:\DHCP\Backup\” –Verbose
After the migration of the DHCP server completed, do not forget to reconfigure the DHCP Relay (IP Helper) agents on the routing network devices.