How to Migrate DHCP to Windows Server 2016?

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):

Add-DhcpServerSecurityGroup

To enable DHCP security settings associated with the local security groups created, restart the DHCP Server service:

Restart-Service DHCPServer

Authorize the new DHCP server in the Active Directory domain:

Add-DhcpServerInDC  host1.contoso.com  192.168.10.35

migrate dhcp from 2008 to 2016

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.

migrate dhcp from 2012 to 2019

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\MicrosoftServerManager\Roles12 –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

migrate dhcp powershell

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.

migrate dhcp server to windows server 2016

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.

Cyril Kardashevsky

6 comments

  1. Hello,
    We have a situation:
    1. A dhcp1 server with about 25 scopes
    2. a dhcpc2 with about 15 scopes
    3. we need to migrate all scopes, leases and reservations from dhcp1 to dhcp2
    4. We want to merge, so we will have all 40 scopes on dhcp2
    5. dhcp1 will be decommissioned as a dhcp server

    Any suggestions?

    1. You’ll need a 3rd DHCP server so move scope 1 and 2 on to dhcp server 3 which will inherit all scopes and be the new primary dhcp server.

      this ensure that any mistakes made will not effect live dhcp servers and you can use them in the event something goes wrong and redo dhcp server 3.

      if you mess up your scope on server 1 and 2 you have no failsafe so it better to migrate both on a new dhcp server and verify before going live and if there are issues turn on both 1,2 respectively.

      if all is well then shutdown scope 1 and 2 and the newly created server 3 will manage all scopes. this way you can verify all scope are on DHCP3 and use that from now on.

  2. Hello
    i tried your DHCP Failover solution and it failed

    I have a failover dhcp server setup and when i use the failover cmd it fails with the message below! and suggestions?

    Import-DhcpServer : Leases cannot be specified when ServerConfigOnly is specified.
    At line:1 char:1
    + Import-DhcpServer -Leases –File “C:\DHCP\OldDHCPConf.xml” -Serv
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Import-DhcpSe
    + FullyQualifiedErrorId : InvalidArgument,Import-DhcpServer

  3. You don’t mention de-authorising or stopping DHCP server service on the old server? What is your recommendation for that? I have done this in a lab environment and having two DHCP servers authorised and started on the same subnet has always been a no-no?

    Also, I am running Server 2019 and the reg hack to remove the Post-deployment Config doesn’t remove the Warning for me – maybe a different reg key in 2019?

    1. I have fixed the Server Manager issue, somehow when I copied the command it did not contain \12 before -name?

      I corrected and re-ran the command and restarted server manager and it’s ok now

  4. Hello,

    On 2012R2, there is a limitation : 31 failover maximum for 1 server.
    Is this limitation the same on 2016 ?
    Thx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.