Microsoft DHCP: How to Export and import scopes between DHCP servers

We are going to use Microsoft’s Netsh command to export and import DHCP scopes from one server and then import them to another.  We run a split scope on two servers for redundancy. So scope one serves the range 172.0.0.64 to 172.0.0.159 and the second server handles 172.0.0.160 to 172.0.0.255. While I was performing maintenance I noticed that in some cases someone missed the creation of the second half of the scope. So to fix this I am going to run a script that will export the scopes. Then I will run another script to import them on the second server. Make sure after wards to modify the exclusion on the second server to be opposite so that they are not both serving the same half.

 

note: the import and export command cannot be ran remotely

Replace 198.168.0.10  with your DHCP server IP address

Replace 198.168.1.0 198.168.2.0 198.168.3.0 with the IP scopes that you are exporting and importing.

Export the scopes for the DHCP server 1

Step 1

  1. Log on to the server that you are exporting from.
  2. open the command prompt
  3. Run the following command from the command prompt on the DHCP server that have the scopes already created.

Netsh DHCP server 198.168.0.10 export c:\scope 198.168.1.0 198.168.2.0 198.168.3.0

 

Step 2

Import the scopes to DHCP server 2  

  1. Copy the scope file to the second DHCP server. 
  2. Log on locally to the second DHCP server, open the command prompts and run the following command to import the scopes

Netsh DHCP server 198.168.0.10 import c:\scope 198.168.1.0 198.168.2.0 198.168.3.0

Step 3

  1. Confirm that the scopes are now on the second server.
  2. Modify the Exclusions if you have any. If this is a split scope then the exclusions should be opposite of each other on the two servers.

 

Good luck.

 

 The following is from Technet http://technet2.microsoft.com/windowsserver/en/library/61427fbd-de1f-4c8a-b613-321f7a3cca6a1033.mspx?mfr=true

import

Imports a DHCP service configuration from a file to the local service.

Syntax

import [Path]FileName {all | ScopeList]

Parameters
[Path] FileName
Required. Specifies, by name, the file from which the DHCP configuration will be imported. If the path, the file name, or both contain spaces, quotation marks must be used.
{all | ScopeList}
Required. Specifies which scopes you want to import. The parameter all imports all scopes represented in the file you specify. The parameter ScopeList imports the scopes that correspond to the IP addresses you list. Each IP address in the list must be separated by spaces.
Remarks
This command works only on the local server.
While the import command runs, the DHCP service is stopped and does not respond to DHCP clients seeking new leases or lease renewals.
If the DHCP service has a large number of scopes or a large number of client address leases, this command can take a long time to run.
Examples

In the first example, this command imports the complete DHCP service configuration from the file c:\Temp\Dhcpdb.

In the second example, this command imports the DHCP configuration for scopes 10.0.0.0 and 192.168.0.0 from the file c:\Temp\Dhcpdb

In the third example, this command imports the complete DHCP service configuration from the file c:\My Folder\Dhcp Configuration. Note that both the path and file name contain spaces, so quotation marks are used.

import c:\Temp\Dhcpdb all

import c:\Temp\Dhcpdb 10.0.0.0 192.168.0.0

import “c:\My Folder\Dhcp Configuration” all

Comments

2 Responses to “Microsoft DHCP: How to Export and import scopes between DHCP servers”

  1. max inglis on July 31st, 2008 8:21 pm

    You sure did blog this up nicely for someone who whined about me not doing it long enough for it to get passed to you :P

  2. Brad Hearn on July 31st, 2008 10:01 pm

    The funny thing is that this one had nothing to do with the original task. While I was working on the first one I found a bunch on discrepancies between the two scopes that spawned this one. Your not the original DNS/DHCP guy are you?

Got something to say?

You must be logged in to post a comment.