How to duplicate reservations from one server to another?

The problematic scenario is the following:

There are two DHCP servers serving the same set of subnets. For each of the subnets which is being served by both the servers there are two scopes one for each server. The scopes are configured in a way that the active address range in one is in the exclusion range of the other. This way we make sure that a particular IP address is not distributed independently of each other. Now there is a small problem if there are reservations. If the admin has configured the reservations in only one of the scopes then he is on for a surprise. The surprise is that the client for whom you have configured the reservation might get a dynamic IP address from the other DHCP server. This can happen in case the DISCOVER sent by the client reaches the server which does not have reservations first. Thus the essential reason for having a reservation is defeated.

The proper way to handle this scenario is: First configure the scope such that the active address range for both the DHCP servers in question is mutually exclusive. Then write a netsh script for the reservations. This script file (let’s call it reservations.txt) would contain for each reservation an entry like:

dhcp server 10.0.0.1 scope 10.0.0.0 add reservedip 11.0.0.1 <MAC ADDRESS>

Now run this script in the first server 10.0.0.1 by typing:

Netsh exec reservations.txt

After this has been done, you might want to use a word processor to replace the IP address of the server 10.0.0.1 to the IP address of the second DHCP server (say 10.0.0.2).

Once this replacement has been done, you can run the script in the second server. Actually the scripts for both the servers can be run from any place from which there is network connectivity to the DHCP servers. This is because almost most of the operations done through netsh is remotable.

Now for the tough part. If you do have two scopes like what I have mentioned and you did not duplicate the reservations then you have to do the following:

On the DHCP server where you have configured the reservations, you can execute this command for each of the scopes from which you need to export the reservations.

netsh dhcp server <serverIPAddress> scope <scopeAddress> dump>dump.txt

This will dump all the configuration settings for this scope. At the bottom of the dumped text file, you can see the reservations being dumped. Just copy this reservation settings to a new file say “exportedreserv.txt”.

Append to this file exportedreserv.txt the reservation settings from each of the other scopes.

Now on the target machine, do a

netsh exec exportedreserv.txt

You should be done by now. I know it is not completely automatic, but it does save a lot of effort.

If you have any questions please ask me. And also try to leave some comments (I know this is moderated) as I would like to know if this blog has any takers.