|
| 1 | +--- |
| 2 | +title: Nested virtualization on a template VM |
| 3 | +titleSuffix: Azure Lab Services |
| 4 | +description: In this article, learn about nested virtualization on a template virtual machine in Azure Lab Services. |
| 5 | +services: lab-services |
| 6 | +ms.service: lab-services |
| 7 | +author: ntrogh |
| 8 | +ms.author: nicktrog |
| 9 | +ms.topic: conceptual |
| 10 | +ms.date: 01/13/2023 |
| 11 | +--- |
| 12 | + |
| 13 | +# Nested virtualization on a template virtual machine in Azure Lab Services |
| 14 | + |
| 15 | +Azure Lab Services enables you to set up a [template virtual machine](./classroom-labs-concepts.md#template-virtual-machine) in a lab, which serves as a base image for the VMs of your students. Teaching a networking, security or IT class can require an environment with multiple VMs. The VMs also need to communicate with each other. |
| 16 | + |
| 17 | +Nested virtualization enables you to create a multi-VM environment inside a lab's template virtual machine. Publishing the template will provide each lab user with a virtual machine that has multiple VMs within it. This article explains the concepts of nested virtualization on a template VM in Azure Lab Services, and how to enable it. |
| 18 | + |
| 19 | +## What is nested virtualization? |
| 20 | + |
| 21 | +Nested virtualization enables you to create virtual machines within a virtual machine. Nested virtualization is done through Hyper-V, and is only available on Windows VMs. |
| 22 | + |
| 23 | +For more information about nested virtualization, see the following articles: |
| 24 | + |
| 25 | +- [How nested virtualization works](/virtualization/hyper-v-on-windows/user-guide/nested-virtualization#how-nested-virtualization-works). |
| 26 | +- [Nested Virtualization in Azure](https://azure.microsoft.com/blog/nested-virtualization-in-azure/). |
| 27 | + |
| 28 | +## Considerations |
| 29 | + |
| 30 | +Before setting up a lab with nested virtualization, here are a few things to take into consideration. |
| 31 | + |
| 32 | +- Not all VM sizes support nested virtualization. When you create a new lab, select **Medium (Nested virtualization)** or **Large (Nested virtualization)** sizes for the VM size. |
| 33 | + |
| 34 | +- Choose a size that provides good performance for both the host (lab VM) and client VMs (VMs inside the lab VM). Make sure the size you choose can run the host VM and any Hyper-V machines at the same time. |
| 35 | + |
| 36 | +- Client VMs don't have access to Azure resources, such as DNS servers, on the Azure virtual network. |
| 37 | + |
| 38 | +- The host VM requires additional configuration to let the client machines have internet connectivity. |
| 39 | + |
| 40 | +- Hyper-V client VMs are licensed as independent machines. For information about licensing for Microsoft operation systems and products, see [Microsoft Licensing](https://www.microsoft.com/licensing/default). Check licensing agreements for any other software you use, before installing it on the template VM or client VMs. |
| 41 | + |
| 42 | +## Enable nested virtualization on a template VM |
| 43 | + |
| 44 | +To enable nested virtualiztion on a template VM, you first connect to the template VM with a remote desktop client. Then, you make a number of configuration changes inside the VM. |
| 45 | + |
| 46 | +1. Follow these steps to [connect to and update the template machine](./how-to-create-manage-template.md#update-a-template-vm). |
| 47 | + |
| 48 | +1. Next, make the following changes inside the template VM to enable nested virtualization: |
| 49 | + |
| 50 | + - **Enable the Hyper-V role**. The Hyper-V role must be enabled for the creation and running of VMs inside the template VM. |
| 51 | + - **Enable DHCP**. When the template VM has the DHCP role enabled, the VMs inside the template VM get an IP address automatically assigned to them. |
| 52 | + - **Create a NAT network for the Hyper-V VMs**. You set up a Network Address Translation (NAT) network to allow the VMs inside the template VM to have internet access and communicate with each other. |
| 53 | + |
| 54 | + >[!NOTE] |
| 55 | + >The NAT network created on the Lab Services VM will allow a Hyper-V VM to access the internet and other Hyper-V VMs on the same Lab Services VM. The Hyper-V VM won't be able to access Azure resources, such as DNS servers, on an Azure virtual network. |
| 56 | +
|
| 57 | +You can accomplish the tasks listed above by using a script, or by using Windows tools. Learn how you can [enable nested virtualization on a template VM in Azure Lab Services](./how-to-enable-nested-virtualization-template-vm-using-script.md). |
| 58 | + |
| 59 | +## Processor compatibility |
| 60 | + |
| 61 | +The nested virtualization VM sizes may use different processors as shown in the following table: |
| 62 | + |
| 63 | + Size | Series | Processor | |
| 64 | +| ---- | ----- | ----- | |
| 65 | +| Medium (nested virtualization) | [Standard_D4s_v4](../virtual-machines/dv4-dsv4-series.md) | 3rd Generation Intel® Xeon® Platinum 8370C (Ice Lake) or the Intel® Xeon® Platinum 8272CL (Cascade Lake) | |
| 66 | +| Large (nested virtualization) | [Standard_D8s_v4](../virtual-machines/dv4-dsv4-series.md) | 3rd Generation Intel® Xeon® Platinum 8370C (Ice Lake) or the Intel® Xeon® Platinum 8272CL (Cascade Lake) | |
| 67 | + |
| 68 | +Each time that a template VM or a student VM is stopped and started, the underlying processor may change. To help ensure that nested VMs work consistently across processors, try enabling [processor compatibility mode](/windows-server/virtualization/hyper-v/manage/processor-compatibility-mode-hyper-v) on the nested VMs. It's recommended to enable **Processor Compatibility** mode on the template VM's nested VMs before publishing or exporting the image. |
| 69 | + |
| 70 | +You should also test the performance of the nested VMs with the **Processor Compatibility** mode enabled to ensure performance isn't negatively impacted. For more information, see [ramifications of using processor compatibility mode](/windows-server/virtualization/hyper-v/manage/processor-compatibility-mode-hyper-v#ramifications-of-using-processor-compatibility-mode). |
| 71 | + |
| 72 | +## Next steps |
| 73 | + |
| 74 | +* Learn how to [enable nested virtualization on a lab VM](./how-to-enable-nested-virtualization-template-vm-using-script.md). |
0 commit comments