So, we updated our DHCP Servers to 2012 R2.
We setup DHCP Failover, which was easy to setup and seems very nice.
But, we don’t see our static reservations migrating.
Did I miss that leases are not part of the cluster, or is there a setting somewhere to have the reservations automatically replicated on the failover server?
Well actually, you need to right-click on IPv4 and/or IPv6 or the individual scope and select Replicate Failover Scopes.
You have to do it every time you make a new reservation.
Well that’s a pain, surely there is a check box? err nope!
Ok a quick google found this:
It is for 2012, does not look like it has been tested on 2012 R2.
Code looks a bit epic and R2 brings some good Powershell cmdlets for DCHP….. lets have a look at the new cmdlets available
hmm here we go…
Invoke-DhcpServerv4FailoverReplication cmdlet looks a winner!
a het-help Invoke-DhcpServerv4FailoverReplication -full gives us some examples!
Well the answer is pretty simple in R2 Powershell does it for you in the one command.
BUT NOTE: This is replication, not syncing, so whatever server you replicate the scopes from will fully overwrite the other servers scopes on the target server.
So if you edit stuff on each server, then replicate one server, the other one’s changes will be overwritten.
Probably best practice is to use one server as the primary server and do all your changes there, then replicate the changes over to the secondary server
anyhow, if you want to replicate, you have options for:
Everything on the server
Invoke–DhcpServerv4FailoverReplication –ComputerName dhcpserver.contoso.com
This example replicates all of the failover scopes on the DHCP server service running on the computer named dhcpserver.contoso.com to one or more respective partner DHCP server services based on one or more failover relationships in which the DHCP server services are included.
A failover relationship
Invoke–DhcpServerv4FailoverReplication –ComputerName dhcpserver.contoso.com –Name SFO–SIN–Failover
This example replicates the configuration of all scopes which are part of the failover relationship named SFO-SIN-Failover on the DHCP server service running on the computer named dhcpserver.contoso.com to the partner DHCP server service
A Particular Scope or Scopes
Invoke–DhcpServerv4FailoverReplication –ComputerName dhcpserver.contoso.com –ScopeId 10.10.10.0,184.108.40.206
This example replicates the configuration of the scopes 10.10.10.0 and 220.127.116.11 to the respective partner computers running the DHCP server services of the failover relationships in which the scopes are included.
Ok so can I schedule this?
No reason why not. but please see note above about replication!
All you need to do is on the “primary” server to:
- Run once on each DHCP server the Add-DhcpServerSecurityGroup to create the local security groups and Add the account to the DHCP Administrators Security Group you want to use in the scheduled task.
- Create a PowerShell file with the command you want
- Schedule a task to run that PowerShell file at whatever interval you want
- Ensure the task runs with the account mentioned in 1.