How to Setup Hyper-V Server on AWS (Nested Virtualization)

To setup and install Hyper-V server on AWS (AWS nested virtualization), you must deploy on one of the AWS bare metal EC2 instances.  You can deploy the Hyper-V server image straight from the AWS marketplace, it fully sets up Hyper-v onto a bare metal server and will allow you to host as many nested guest VMs as you like using the hypervisor:

Getting Started


AWS Metal instances can take a while to boot up, so it may take upto 30mins for the server to be fully deployed before you can login


Once Hyper-V your server has been deployed, the following links explain how to connect to a Windows VM:



Once connected and logged in, the following section explains how to configure Hyper v as per your requirements

Configure Hyper-V Networking for AWS


To enable networking for your Hyper-V guests—so they can have connectivity to other resources in your VPC, or to the internet via your VPC internet gateway, ensure that you have first configured your VPC. For more information, see Creating and Attaching an Internet Gateway.


Hyper-V provides three types of virtual switches for networking:


Hyper-V provides 3 types of virtual switches for networking:


  • External
  • Internal
  • Private


In this solution, you are creating an internal virtual switch and using the Hyper-V host as the NAT server for the guest VMs, similar to Microsoft’s topic Set up a NAT network.


You can specify your own virtual network range. For this example, use as the range for the virtual network inside the Hyper-V host.


1.) Run the following Powershell command, to create the internal virtual switch:

New-VMSwitch -SwitchName "Hyper-VSwitch" -SwitchType Internal

2.) Now we need to determine which NIC is associated with the virtual switch.  Run the Get-NetAdapter Powershell command to find the ifIndex. As you can see mine is 12




3.) Next, Configure the Hyper-V Virtual Ethernet adapter with the NAT gateway IP address. This IP address is used as the default gateway (Router IP) for the guest nested VMs. The following command sets the IP address with a subnet mask on the Interface (InterfaceIndex 12):

New-NetIPAddress -IPAddress -PrefixLength 24 -InterfaceIndex 12

4.) Create a NAT virtual network using the range of

New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix

Now the environment is ready for you to start deploying guest VMs and for the VMs to have outbound communication with other resources through the host NAT. For each VM, assign an IP address with the default gateway ( This can be done manually within each guest VM. However if you are thinking of deploying many VMs, you can make it easier by enabling a DHCP server within the Hyper-V host to automatically assign IP addresses.  The next section explains how to setup a DHCP server.

Setup DHCP Server for Hyper-V Guest VMs


If you would like to automate the deployment of IP address to your Hyper-V guest VMs, the easiest way is to deploy a DHCP server on your Hyper-V host.


1.) Run the following Powershell command on your Hyper-V Host:

Install-WindowsFeature -Name 'DHCP' -IncludeManagementTools

2.) To configure the DHCP server to bind on the Hyper-V virtual interface, open Administrative Tools, DHCP


3.) Select this computer, add or remove bindings, and then select the IP address corresponding to Hyper-V virtual interface (that is,


4.) Configure the DHCP scope and specify a range from the subnet that you determined earlier. In this example, use


Run the following Powershell command:

Add-DhcpServerv4Scope -Name GuestIPRange -StartRange -EndRange -SubnetMask -State Active

Within the DHCP console you should now see your address range:


5.) For Router, choose the NAT gateway IP address assigned it to the Hyper-V network adapter (

6.) For DNS server, use the Amazon DNS, which is the second IP address for the VPC (

Create Hyper-V Guest VM


I would recommend first downloading your OS ISO that you will use to setup your new VMs.  Place the ISO file on a secondary EBS volume that you added as the D: drive.


I3.metal instances use Amazon EBS and instance store volumes with the NVM Express (NVMe) interface. When you stop an I3.metal instance, any data stored on instance store volumes is gone. I recommend storing your guest VM’s hard drive (vhd or vhdx) on an EBS volume that is attached to your I3.Metal instance. This can be the root volume (C:) or any additional EBS volumes attached to the instance. For more information, see What’s the difference between instance store and EBS?


Here are links if you want download Windows or Ubuntu:


Windows Server 2019 Evaluation ISO


Ubuntu Server 20.04 LTS


You’re now ready to start setting up guest VMs. You do this via Hyper-V manager.  Choose Actions > New > Virtual Machine


2.) Follow the wizard with your desired configuration up to the Configure Networking section.
3.) In the Configure Networking step, for Connection, choose Hyper-V Switch, and choose Next.
4.) In the Connect Virtual Hard Disk step, enter a name for the virtual hard disk. Use the default location C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\.
5.) Specify the size of the virtual hard disk, and choose Next.
6.) In the Installation Options step, choose the ISO that you downloaded earlier.
7.) Finish the wizard and start the VM, then follow the steps on the OS installation wizard. As you have already set up DHCP and NAT for the Hyper-V network, the new VM automatically gets an IP address from the DHCP scope that you defined earlier.
8.) Confirm the connectivity of the VM to the internet

AWS Firewall Ports


If you experience any networking issues, confirm if you have any AWS security groups setup and if so, open the required ports you may need:


To setup AWS firewall rules refer to – AWS Security Groups

Avatar for Andrew Fitzgerald
Andrew Fitzgerald

Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x