Wednesday, January 23, 2013

How to migrate the DHCP service to Windows 2012

One of my customers asked me to dismiss an old Windows 2003 R2 server which is running the DHCP service for a bunch of workstations and to replace it with a new Windows 2012 server we installed last December.

Seen the fact that this DHCP service is configured with many options and a lot of reservations, and that I am totally lazy about recreating all these settings manually, I found a way to dump its configuration to a text file and to import it back to Windows 2012.

Let's start exporting the DHCP database from the server that is running Microsoft Windows Server 2003 with the command:

netsh dhcp server export C:\dhcp_config.dat all
This generates the binary file C:\dhcp_config.dat. After this operation has completed, stop the DHCP service:
net stop "dhcp server"
Now let's log on to the Windows 2012 server and, after having set it up with a manually assigned IP address, install the DHCP service using Powershell, of course:
Import-Module ServerManager
Add-WindowsFeature -IncludeManagementTools dhcp
As you can see we need to happend the "IncludeManagementTools" switch, otherwise just the DHCP server role would be installed and not the management console.

The next step is to authorize the DHCP server in Active Directory, otherwise it will be considered as rogue. To do so:
Add-DhcpServerInDC  dhcpservername  dhcpipaddress
The last step is to import the dump of the configuration from the old server:
netsh dhcp server import \\dhcpservername\c$\dhcp_config.dat all
A restart of the DHCP service and that's all:
restart-service dhcp
Hotpe this helps and feel free to comment.

5 comments:

  1. Everytime I do this I get "Access Denied" trying to import. The 2012 server is a domain controller and I am logged in as a domain admin. Any ideas?

    ReplyDelete
    Replies
    1. Maybe you are not running an elevated Powershell session? Can you check?

      Delete
  2. Worked great for me. Thanks a bunch!

    ReplyDelete
  3. Great step-by-step instructions. The only step I had to modify was

    restart-service dhcp

    applied only to the dhcp client and not the server. changed it to

    restart-service dhcpserver

    ReplyDelete
  4. I have the problem, that my reserved adresses after the import at the 2012 server are not there?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...