Hyper-V and DHCP Guard Feature
With Windows Server 2012, Microsoft added Hyper-V DHCP Guard feature. This feature can be enabled on VM NICs and it discards DHCP Offer messages.
Below is a figure about DHCP Lease process:
When DHCP Offer packets are blocked, a DHCP server cannot offer an IP address.
How DHCP Technology Works: http://technet.microsoft.com/en-us/library/cc780760(v=ws.10).aspx
In other words, this feature blocks virtual machines from acting as DHCP servers. This feature is very useful to prevent rogue DHCP servers running on VMs in your Hyper-V environment.
How to enable Hyper-V DHCP Guard feature using UI?
- Using Hyper-V Manager administrative tool, do a right click on your VM and then click on Settings…
- Go to Advanced features under the VM NIC and then check Enable DHCP Guard option. Once done, click on OK
How to enable Hyper-V DHCP Guard feature using PowerShell?
Set-VMNetworkAdapter with DhcpGuard switch can be used to enable DHCP guard on VM NICs.
Set-VMNetworkAdapter: http://technet.microsoft.com/en-us/library/hh848457.aspx
We can take the following example which enables DHCP Guard feature on all NICs for Server1 VM:
Get-VMNetworkAdapter –VMName Server1 | Set-VMNetworkAdapter –DhcpGuard on |