DHCP Database in Windows Server 2003

Perhaps you have never given the DHCP database a thought.  Well the time may come where you need to backup, reconcile or compact the DHCP database.  At the very least, I expect you will want to check your lease statistics.

 

DHCP - Display Statistics

 

Bizarrely, I find 'Display Statistics' the most difficult tab to find on the DHCP server.  This is because it's the first item on the menu, and is often masked by the very highlight that should attract me.  I just hope that you are not afflicted by this blind spot. In any event, Display Statistics is one of the most interesting and rewarding items on the DHCP menu.

 

Display Statistics is available at both the server and the scope level.  My first thought is, 'How many leases are left?'  Next, I look to see if there have been any NACKS or lease declines.  See the screen shot to find the Display Statistics... menu.

 

DHCP Database  

 

DHCP has its own database.  Stored in this DHCP.mdb are the addresses, scopes and leases of the clients.  Understanding this database will help you backing up and restore a DHCP server.

 

Check out this folder: %systemroot%\system32\dhcp\dhcp.mdb

 

As time goes by the database will grow, and best practice dictates that you should consolidate the database by freeing up space taken up by old leases.

 

The procedure for compacting the dhcp.mdb database is this.

 

  1. Stop the DHCP service.  Either right click the DHCP Server icon, select All tasks then Stop.  Alternatively, go to the command line and type: NET Stop DHCPServer.  (For once the command really is DHCPserver, NOT DHCPyourservername.)
     
  2. At the command line, navigate to: %systemroot%\system32\dhcp\dhcp.mdb.
     
  3. Jetpack dhcp.mdb temp.mdb. What this does is copies the existing database, compacts it, then copies it back to the original location - clever.
     
  4. Remember to restart DHCP.  Either use the GUI, or if you are at the command line, NET Start DHCPServer

 

Warning: Do not 'mess' with any of the files that you find in the %systemroot%\system32\dhcp folder, if you do, then DHCP will stop working and you will either have to restore, or else re-install DHCP.

 

 

Backing up the DHCP Database

 

  • The first surprise is that this dhcp.mdb database is backed up every hour.
     
  • The second surprise is that the old jetpack database engine controls the database.
     
  • The third surprise is that you can only automatically backup to a local folder.  Should you need a 'real' backup, then just backup the files in the %systemroot%\system32\dhcp\Backup\ directory.
     
  • Finally, and unsurprisingly, there is a GUI to backup the DHCP database.

 

Reconcile

 

Reconcile is a technical term for making sure that DHCP information is consistent.  What can happen is that when you restore a database, there is a miss-match between lease information in the database and the same information in the DHCP server's registry.  Specifically, the registry just stores basic or summary information, the detailed information from a recent restore maybe different, so a 'Reconcile' will ensure that the database and registry data are consistent once more.

 

Bear in mind that you can either reconcile individual scopes or choose all scopes.  It all depends on the 'focus' of what you select.  If you select an individual scope that that is the limit of what you can reconcile, however, when you select the server icon, you can: Reconcile All Scopes.