Disable DHCP on Hyper-V created vSwitch Host NICS. #hyperV #dhcp #hosthijack

So playing with Hyper-V the past few weeks quite a bit and noticed that when creating a vSwitch, no matter if External and bridged to a real NIC on the host or not, it will create a NIC on the Windows host machine correlating to the vSwitch in Hyper-v. If you create a virtual machine, and attach it to the vSwitch, and this virtual machine is running a DHCP server, your HOST NIC for that vSwitch will pull a DHCP address from the VM, instead of just acting as an interal bridge and sending the traffic to it’s destination. This is very undesired (and honestly scary), as I am testing a lot of VM’s that I don’t know who built them, how they are configured, if they are malicious etc. I do not want my Hyper visor pulling DHCP from VM’s, that’s just stupid.

So to resolve this issue I forced DHCP to be disabled, and also did not assign a static IP causing the interface to default to the 169.xx.xx.xx address that windows does when it cannot pull a DHCP address.

Doing this from my work computer so don’t have the Hyper-V NIC names atm, will update later. (For now below example will disable DHCP on Ethernet “ifIndex 2” interface.)

 PS C:\WINDOWS\system32> Get-NetAdapter
 Name                      InterfaceDescription                    ifIndex Status    

 Wi-Fi                     Intel(R) Centrino(R) Advanced-N 6205         11 Disconnected

 Ethernet                  Intel(R) Ethernet Connection I217-LM          2 Up          

PS C:\WINDOWS\system32> Set-NetIpInterface -ifindex 2 -Dhcp Disabled
PS C:\WINDOWS\system32>

The NIC will drop the IP from the VM on that vSwitch, and assign a default 169.xx.xx.xx address after doing this.