Wednesday, February 12, 2014

Moving DHCP from one server to another and keeping all leases.

Moving DHCP from one server (2003-2012) to another, preserving all settings AND MOST IMPORTANTLY leases!

1.   Log on to the source DHCP server by using an account that is a member of the local Administrators group.
2.   Click Start, click Run, type cmd in the Open box, and then click OK.
3.   Type netsh dhcp server export C:\dhcp.txt all , and then press ENTER.

Configure the DHCP server service on the new server.
1.   Click Start, click Administrative Tools, click Server Manager. If needed acknowledge User Account Control.
2.   In Roles Summary click Add Roles, click Next, check DHCP server, and then click Next.

Import the DHCP database
1.   Copy the exported DHCP database file to the local hard disk of the new server.
2.   Verify that the DHCP service is started on the new server.
3.   Click Start, click Run, type cmd in the Open box, and then click OK.

4.   At the command prompt, type netsh dhcp server import c:\dhcp.txt all , and then press ENTER, where c:\dhcp.txt is the full path and file name of the database file that you copied to the server.

2 comments:

  1. How would you do this with a Split Scope setup? Two Server 2008 R2 to a single 2012 R2?

    ReplyDelete
  2. My first reaction would be, keep two DHCP servers in case one goes down.

    If that's not an option, I would first lower the lease time to 1 day on both servers, then get rid of one and expand the scope on the other. Then I'd migrate that one to the new server. If it's 08 R2 to 2012, I'd use powershell instead of netsh.

    Create a folder on the new DHCP server – C:\export. Open an administrator powershell session. Run the following command to export remotely from the old DCHP primary server:
    Export-DhcpServer –ComputerName Oldserver.domain.local -Leases -File C:\export\dhcpexp.xml –verbose
    Next, create a backup path for the DHCP server database on the new DHCP server – C:\dhcp\backup. Then, import the old DHCP server configuration using the following command:
    Import-DhcpServer –ComputerName Newserver.domain.local -Leases –File C:\export\dhcpexp.xml -BackupPath C:\dhcp\backup\ -Verbose

    ReplyDelete