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