Introduction
In the world of networking, the Microsoft DHCP Server holds significant importance. It simplifies the management of IP addresses by automatically assigning and managing them within a network. This vlog will provide a brief overview of the DHCP Database, its files, and working with the database. We will also touch upon topics like backup and restore, reviewing DHCP console icons, troubleshooting DHCP clients, DNS integration, and server migration.
DHCP Database
The Windows Server DHCP Database is a storage system that holds important information for the DHCP (Dynamic Host Configuration Protocol) server. It keeps track of IP address ranges, known as “scopes,” and the IP addresses that have been assigned to devices. The database helps the DHCP server efficiently manage and distribute IP addresses to devices on the network. It ensures that each device gets a unique IP address and allows for easy tracking and management of these addresses.
DHCP Database
-Stores scopes and leases
-Joint Engine Technology
-Uses transaction logs
DHCP Database Files
-j50.log and j50xx.log
-j50.chk
-dhcp.mdb
-temp.edb
-IPv4 and IPv6 server logs
-J50resxx.jrs
Working with the DHCP Database
#Maintaining DHCP
#region Database
#view Database files on Dcl
start iexplore.exe \\dcl\c$\windows\system32\dhcp
#Change DHCP automatic backup timing |
#Browse to Network Registry via Registry Editor
#HKLM: \SYSTEM\CurrentControlSet\Services\DHCPServer
regedit
#Reconcile through GUI
Reconcile-DhcpServerv4IPRecord `
-ScopeId 192.168.3.0 `
-ComputerName DC1 `
-Reportonly
#endregion
- View Database Files: This command opens the File Explorer on a DHCP server named Dcl, allowing you to browse and access the DHCP database files.
- Change DHCP Backup Timing: This command opens the Registry Editor, where you can navigate to a specific registry path related to DHCP settings. From there, you can modify the backup timing settings for DHCP.
- Reconcile DHCP Server IP Records: This command performs a reconciliation process for the IP address records within a specific DHCP scope. In this example, it reconciles the IP records for the scope with the ID “192.168.3.0” on a DHCP server named DC1. The “-Reportonly” parameter ensures that only a report is generated without making any changes to the IP records.
Backup and Restore of DHCP Database
#Maintaining DHCP
#region Database…
#region DHCPBackup
#gui
#Backup to c:\DHCPBackup
#Delete Scopes
#Restore and verify
#Scenario: You need to backup up the DHCP database and perform a test restore.
Invoke-Command -ComputerName DC1 {…}
#backup one-time to defined location
Backup-DhcpServer -ComputerName DCl -Path \\dc1\c$\DHCPBackup2
Invoke-Command -ComputerName DC1 {…}
#Remove Scope
Remove-DhcpServerv4Scope -ScopeId 192.168.3.0 -ComputerName DC1 -Force
Remove-DhcpServerv4Scope -ScopeId 192.168.4.0 -ComputerName DC1l -Force
Remove-DhcpServerv4sScope -ScopeId 192.168.5.0 -ComputerName DCl -Force
Get-DhcpServerv4Scope -ComputerName DC1
#Restore DHCPServer
Restore-DhcpServer -ComputerName DCl -Path \\dcl\c$\DHCPBackup2 -Force
Invoke-Command -ComputerName DC1 -ScriptBlock {
Restart-Service -Name DHCPServer -Force
}
Get-DhcpServerv4Scope -ComputerName DC1
Get-DhcpServerv4Lease -ScopeId 192.168.3.0 -ComputerName DC1
#endregion DHCPBackup
- Remove Scopes: This section removes DHCP scopes from the server.
- ScopeId: The commands remove DHCP scopes with the specified ScopeIds (“192.168.3.0”, “192.168.4.0”, “192.168.5.0”).
- ComputerName: The commands target a DHCP server named DC1.
- Force: The “-Force” parameter ensures that the removal is performed forcefully without prompting for confirmation.
- Restore DHCP Server: This section involves restoring the DHCP server from the backup.
- Path: The backup path is specified as “\dcl\c$\DHCPBackup2”.
- Force: The “-Force” parameter ensures that the restore process is performed forcefully.
- Restart Service: The DHCP server service is restarted to apply the changes.
- Get-DhcpServerv4Scope: These commands retrieve information about the DHCP scopes on the server.
- Get-DhcpServerv4Lease: This command retrieves lease information for a specific DHCP scope
These commands help in maintaining the DHCP server by performing backups, removing scopes, restoring from backups, and verifying the server’s status and leases.
Reviewing DHCP Console Informational Icons
#Maintaining DHCP
#region Database…
#region OHCPBackup…
#region DHCPInfo
#View Icons for DHCP Console and Review
Start iexplore.exe “https://technet.microsoft.com/en-us/library/gg722802 (v=ws.10).aspx”
#Review DHCP Server Info
Get-DhcpServerv4Statistics -ComputerName Dcl
Get-DhcpServervéFreeIPAddress -ComputerName DC1 -ScopeId 192.168.3.0
get-service -ComputerName DC1 -Name DHCPServer
#Gather Scope information
Get-DhcpServerv4scope -ComputerName DC1
Get-DhcpServerv4Scope -ComputerName DC1 -ScopeId 192.168.3.0 | format-list
Get-DhcpServerv4optionvalue -ComputerName DC1 -All | f1
Get-DhcpServerv4Optionvalue -ComputerName DC1 -All -ScopeId 192.168.3.0|f1
#Review Event Logs
#Configure DCcl for remote event reading using Event Viewer
Invoke-Command -ComputerName Dc1{
Set-NetFirewallRule `
-DisplayGroup ‘Remote Event Log Management’ `
-Enabled True -PassThru |
select DisplayName, Enabled
}
eventvwr.msc
#endregion DHCPInfo
Gathering DHCP Server Information
GUI Steps
In DHCP CONSOLE, Right click the vm.microsoft.com properties — For Database path
Right click IPV4 and Display statistics
Troubleshooting a DHCP Client
#region troubleshooting
#Stop DHCPServer to simulate Outage
Invoke-Command -ComputerName dcl { stop-service DHCPServer }
#check on cli2
ipconfig /all
Get-NetIPAddress
ipconfig /release
ipconfig /renew
get-netipadress
#Note: 169.254…
#Investigate
Get-DhcpServerSetting -ComputerName dc1
Invoke-Command -ComputerName dc1 F get-service DHCPServer }|
#Restart Service
Invoke-Command -ComputerName dcl { start-service DHCPServer }
Get-DhcpServerSetting -ComputerName dcl
#Command.exe legacy commands
DNS Integration with DCHP
- DNS dynamic updates:This features work with client receiving ip address to update their DNS records, whenever a DHCP is issued
- DNS name protection
Prevents name squatting by non-windows-based computers, so name protections based on DHCP database to prevent duplicates DHCID RR
Implementing DNS Dynamic Updates and Name Protection
GUI Steps
FOR DYNAMIC UPDATES
- DHCP CONSOLE
- Right click ipv4
- properties
- DNS
- Enable Dynamically.
FOR NAME PROTECTIONS
- DHCP CONSOLE
- Right click ipv4
- properties
- DNS
- Configure
- check the BOX — ENABLE NAME PROTECTION
Migrating DHCP Server
DHCP Migration
When moving DHCP from server 2008 to 2016
TWO IMPORANT SETS OF INFORMATION
- DHCP DATABASE
- DHCP SERVER SETTINGS
Planning for migration?
- Verify pre-requisites
- Backups
- Prepare servers
- Back out plan
Planning for Migration
Prepare Servers — SERVERS
Perform migration tasks — Using PowerShell is the quickest way
Verify migration — check the dhcp server services , scopes etc.
Roll back on fail
Migration Tools
USING COMMANDLINE AND POWERSHELL
Legacy migration with netsh
— — — — — — — — — — — — — — –
2008/2008 R2
2012/2012 R2
With “netsh” you can export the dhcp configuration and import it as well.
Modern migration with PowerShell
— — — — — — — — — — — — — — — — –
2012/2012 R2
2016
PowerShell is the way to go with export dash dhcp server with import dash dhcp server.
NOTE : YOU BETTER DOCUMENT IT
Migration and Migration Tools
Take a snapshot before doing
cd c:\Autolab…….
snapshot-lap
Migrating with Netsh
DHCP MIGRATION WITH NETSH SOURCE CODE :
Migrating with PowerShell
Conclusion
In conclusion, understanding the Microsoft DHCP Server and its functionalities is crucial for efficient network administration. From the DHCP Database storing scopes and leases to working with database files, backup and restore operations, and troubleshooting DHCP clients, each aspect contributes to maintaining a stable and well-functioning network environment. Additionally, integrating DHCP with DNS for dynamic updates and implementing name protection further enhances network reliability. Lastly, when it comes to server migration, having a clear plan and utilizing appropriate migration tools ensure a smooth transition of DHCP services.