Switching dynamic IP to static in VMM

Creating a VM from virtual disk or existing virtual machine is a basic task in every VMM infrastructure. What if you want to assign IP from static pool instead of dynamic which is just the one option by default for such deployments? Well,doing this in wizard, will end by receiving a warning:“You cannot customize IP settings for a stored virtual machine or a virtual hard disk. You can only customize IP settings if you use a VM template” and static IP pool will be grayed out.

vmm static ip pool greyed out

If you don’t want to create VM template for some reason, PowerShell will help you to fix this behavior. Just start VM creation wizard, edit hardware and other settings and leave Dynamic IP for network adapter. Then don’t run VM and execute the following PowerShell script:

#Get VM
$vm=Get-SCVirtualMachine -Name "rl-srv-01.demolab.com"

#Get static pool which you are going to use with that VM (here I'm filtering pool by address range)
$pool=Get-SCStaticIPAddressPool|? {$_.IPAddressRangeStart -eq "10.10.25.1"}

#Grant changes
Grant-SCIPAddress -GrantToObjectType "VirtualNetworkAdapter" -GrantToObjectID $vm.VirtualNetworkAdapters[0].ID -StaticIPAddressPool $pool

#Update network adapter settings
Set-SCVirtualNetworkAdapter -VirtualNetworkAdapter $vm.VirtualNetworkAdapters[0] -IPv4AddressType static

Go back to the VM settings and check changes that script has successfully made:

vmm dynamic to static ip pool result

How to enable nested virtualization in Azure

We have already mentioned new Azure VM series Dv3 and Ev3 which enable running VMs inside Azure VMs or just nested virtualization. Today we are going to get it configured and to run our first nested VM in Azure.

But before we start, let’s review some Dv3 and Ev3 facts:

  • they introduce Hyper-Threading Technology running on the Intel® Broadwell E5-2673 v4 2.3GHz processor and Intel® Haswell 2.4 GHz E5-2673 v3
  • they made shift from physical core to virtual CPUs (thanks to HT technology) to support larger VM sizes
  • they are the first Azure VMs running on Windows Server 2016 hosts
  • Dv3 VMs are up to 64 vCPUs and 256 GB RAM
  • Ev3 VMs are up to 64 vCPUs and 432 Gb RAM
  • they are currently available only for certain regions (West Europe, US East, US West 2, Asia Pacific Southeast)
  • they already come with ExposeVirtualizationExtensions enabled. we don’t need to enable CPU extensions as we have to do for on-premises WS2016 hosts

To get started with “nesting” you need to create one or more Dv3/Ev3 VMs in Azure within compatible region. For quick demo purposes, I created D2S_V3  VM with Windows Server 2016 DC , standard managed disk with no data disks attached.

TIP: actually you can , for instance, create 2 or more VMs , add data disks and configure storage spaces between them to achieve higher IO performance.

Then you need to install Hyper-V role and restart VM to apply changes

Install-WindowsFeature Hyper-V -IncludeManagementTools -Restart

nested virtualization azure 1

Verify that Hyper-V role is installed and add internal switch. New adapter “vEthernet (switchname)” will be created under network connections list (ncpa.cpl)

Define a new IP address for this adapter (I’m using 192.168.0.0/24 subnet).  This network will be used as a NAT gateway for new VMs in order to allow internet access from nested VMs.

#Check Hyper-V role state
Get-WindowsFeature Hyper-V|ft InstallState, PostConfigurationNeeded

#Add new internal switch
New-VMSwitch -SwitchName "NSW01" -SwitchType Internal

# IP Configuration for vNIC
New-NetIPAddress -InterfaceAlias "vEthernet (NSW01)" -IPAddress 192.168.0.23 -PrefixLength 24

nested virtualization azure 2

Configure NAT rule to provide “access” to our nested VMs

New-NetNat -Name Nat_VM -InternalIPInterfaceAddressPrefix 192.168.0.0/24

image

Now our nested VMs can assign IP addresses from 192.168.0.0/24 subnet  (manual assignment). If you want to have dynamic IP assignment – create add. VM and configure DHCP. Continue reading “How to enable nested virtualization in Azure”