Windows Server DHCP Failover: Load Balance vs Hot Standby - 夜莺博客

Windows Server DHCP Failover: Load Balance vs Hot Standby

Two Windows DHCP servers sharing one logical scope have been native since Windows Server 2012, yet failover pairs are still commonly built with split scopes and manual reconciliation. The native feature replicates lease information over TCP 647 continuously, so clients keep getting the same address and existing leases survive a server loss. This guide covers both modes, the tuning values that matter, and how to verify that replication is actually working before you need it.

Load Balance vs Hot Standby

Load balance mode is active-active: both servers answer clients based on a hash of the client MAC address, in the ratio you configure (50/50 by default). Hot standby assigns explicit roles - the active server handles everything and the standby holds a reserve percentage of the scope for new leases during an outage. Choose load balance when both servers are equally reachable and located together; choose hot standby for a DR site or when the secondary hardware is weaker.

Prepare Both Servers

Install-WindowsFeature DHCP -IncludeManagementTools

# Run on each server, using its own FQDN and address
Add-DhcpServerInDC -DnsName dhcp01.corp.example.com -IPAddress 192.168.1.10
Set-DhcpServerv4Binding -ComputerName localhost -BindingAddress 192.168.1.10

Authorise both servers in Active Directory from a management host with RSAT. An unauthorised DHCP server in an AD domain will not respond to clients, which looks exactly like a network outage.

Create the Scopes

Add-DhcpServerv4Scope -Name "Office-LAN" -StartRange 192.168.10.50 `
  -EndRange 192.168.10.250 -SubnetMask 255.255.255.0
Set-DhcpServerv4OptionValue -ScopeId 192.168.10.0 -Router 192.168.10.1
Set-DhcpServerv4OptionValue -ScopeId 192.168.10.0 -DnsServer 192.168.1.5,192.168.1.6

Create the scope on one server only. The failover relationship creation replicates it to the partner; if the scope already exists on both, the relationship cannot be created and returns an error.

Create the Failover Relationship

$secret = Read-Host "Shared secret" -AsSecureString
$plain  = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
            [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secret))

Add-DhcpServerv4Failover -Name "Office-LAN-Failover" `
  -PartnerServer "dhcp02.corp.example.com" `
  -ScopeId 192.168.10.0 `
  -SharedSecret $plain `
  -LoadBalancePercent 50 `
  -MaxClientLeadTime 1:00:00 `
  -AutoStateTransition $true `
  -StateSwitchInterval 0:60:00

For hot standby, swap the mode and give the standby a reserve pool:

Add-DhcpServerv4Failover -Name "Office-LAN-HS" `
  -PartnerServer "dhcp02.corp.example.com" `
  -ScopeId 192.168.10.0 `
  -SharedSecret $plain `
  -Mode HotStandby -Role Standby -ReservePercent 20

The Two Values That Decide Your Failover Behaviour

MaxClientLeadTime (MCLT) is how long a partner may extend a lease beyond the last state it learned from its peer. One hour is the usual starting point. Lowering it makes failover grant addresses faster but increases the risk of duplicate grants if replication lags across a slow WAN link.

AutoStateTransition and StateSwitchInterval control whether the partner automatically moves from COMMUNICATION INTERRUPTED to PARTNER DOWN. Enable them only when a communication failure really means the partner is gone; if the two servers sit across an unreliable link, automatic transition can create a split-brain where both servers serve addresses.

Verification

Get-DhcpServerv4Failover
Get-DhcpServerv4Failover -Name "Office-LAN-Failover" | Format-List
Get-DhcpServerv4ScopeStatistics
Get-DhcpServerv4Lease -ComputerName dhcp02 -ScopeId 192.168.10.0

Check three things: the relationship state must be Normal, leases created on one server must appear on the partner within seconds, and the partner must hold the same scope options. Then test for real - stop the DHCP service on the primary and confirm a new client can still obtain an address. For relay and option handling on the network side, see DHCP option 82 relay agent information and Cisco ip helper-address DHCP relay.

原文链接:https://learn.microsoft.com/en-us/windows-server/networking/technologies/dhcp/manage-dhcp-failover-relationships