Introduction
DHCP failover is a feature in Windows Server that provides high availability and load balancing for DHCP servers. It ensures that DHCP services remain accessible even if one server fails. There are two modes of failover: Hot Standby and Load Balancing.
Microsoft DHCP Server – DHCP Failover
In the box
Easy to install n configure feature
Requirements
- 2 servers with DHCP role installed
- 1 server configured with scopes
DHCP Failover Modes
There are two options!
Hot Standby
- Active-Passive failover
- Best suited for branch office
In Hot standby mode to servers are operate in failover relationship
and active server responsible for releasing IP address and configuration information to all the client in a scope or subnet the secondary server assumes its responsibility, if the primary server becomes unavailable, a server is primary And One primary server for one subnet can be secondary for another subnet.
Load Balancing
- Active-Active failover
- Both servers active
- Best suited for same-site deployments
In Load balancing (default mode of operation), the two servers simultaneously serve IP address and options to clients on a given subnet. this is known as active — active failover.
so both are active in this scenario
Implementing Load Balanced Failover
PowerShell
#region Add DC1 as DHCP Server
Install-WindowsFeature -ComputerName DC1 DHCP
Add-DhcpServerInDC -DnsName dc1.microsoft.com
#endregion
GUI
You can configure failover to both single scope and IPV4 option
Primary DHCP Console
Ipv4
Scope — right click
configure failover
Failover wizard
choose partner server and authorize it with the Mode option you choose “Load Balancing”
50% 50% which means 50% ip address will be given to one server and other 50% to other server. “mac address” hashing done by both servers
State switch, the time for shifting servers (mostly works with hot standby mode)
Implementing Hot Standby Failover
GUI
Primary DHCP Console
Ipv4
Scope — right click
configure failover
Failover wizard
Choose partner server and authorize it. with the Mode option you choose “Hot Standby”.
Select whether its active or standby.
Reserve Percentage — that this standby server will keep for that period when the main server goes down, and the partner server hasn’t fully come up and take full control over DHCP
State switch — we can add a time (60 Min)where standby will come up and say Hey IM the OFFICIAL SERVER now
- Right click the failover scope or ipv4 properties
- You will see a FAILOVER TAB
Implementing DHCP Failover with PowerShell
#region — Create Failover
#View Commands
gcm -Name *v4failover*
#Get current failover on s1 and remove
Get-DhcpServer4Failover -ComputerName s1 |
Remove-DhcpServer4Failover -Force -ComputerName s1
Get-DhcpServer4Failover -ComputerName s1
#Get all existing scopes
$ipv4scopes = Get-DhcpServer4Failover -ComputerName s1.microsoft.com
#Create Failover Relationship
Add-DhcpServer4Failover `
-Computer S1.microsoft.com`
-Name S1-DC1-Failover `
-Partnerserver DC1.microsoft.com `
-ScopeId $ipv4scopes.ScopeID `
-LoadBalancePercent 70 `
-MaxClientLeadTime 2:00:00 `
-AutoStateTransition $true `
-StateSwitchInterval 2:00:00
Get-DhcpServer4Failover -ComputerName s1
Get-DhcpServer4Failover -ComputerName DC1
#endregion
#region Add Failover Scopes
#New Scope
Add-DhcpServer4Scope -ComputerName s1 `
-Description ‘Scope’ `
-Name ‘6.0 future scope’ `
-StartRange 192.168.6.100 `
-EndRange 192.168.6.254 `
-SubnetMask 255.255.255.0 `
-LeaseDuration 08:00:00 `
-Type Dhcp `
-State Active
Add-DhcpServer4FailoverScope
-ComputerName s1 `
-ScopeId 192.168.6.0 `
-Name s1-DC1-Failover
Get-DhcpServer4Failover -ComputerName s1
Get-DhcpServer4Failover -ComputerName DC1
#endregion
Maintaining DHCP Failover
#region — Maintaining Failover
#Change LoadBalancePercent and add message authentication with shared secret
Set-DhcpServer4Failover `
-ComputerName s1 `
-Name s1-DC1-Failover `
-SharedSecret “admin” `
-LoadBalancePercent 50
Get-DhcpServer4Failover -ComputerName s1
Get-DhcpServer4Failover -ComputerName DC1
#FOrce Replication of settings
Invoke-DhcpServer4FailoverReplication `
-ComputerName s1 `
-Name s1-DC1-Failover
#View DHCP Statistics
Get-DhcpServer4ScopeStatistics `
-ComputerName s1 `
-ScopeId 192.168.3.0 `
-Failover | fl
#Modify Failover for Maintenance
Set-DhcpServer4Failover `
-ComputerName s1 `
-Name s1-DC1-Failover `
-LoadbalancePercent 100
Get-DhcpServer4ScopeStatistics `
-ComputerName s1 `
-ScopeId 192.168.3.0 `
-Failover | fl
#endregion
Conclusion
Implementing and maintaining DHCP failover is crucial for ensuring high availability and reliability of DHCP services in a network environment. By configuring failover between two DHCP servers, organizations can ensure uninterrupted IP address assignment and configuration for their clients.
The two failover modes, Hot Standby and Load Balancing, offer different approaches to achieving DHCP high availability. Hot Standby mode allows one server to act as the primary server, serving clients while the secondary server remains in standby mode. In case of primary server failure, the secondary server takes over the DHCP responsibilities. Load Balancing mode, on the other hand, allows both servers to actively serve IP addresses and options to clients simultaneously, distributing the load evenly between them.