April 17, 2024
103118 0046 HyperVneste65 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure
As we know, you can easy to create VMs, Firewalls, Load Balancers on Microsoft Azure, you also can make routing path change but all of them will cost you lots of money, it depends on how many virtual devices or virtual machines that you created.

As we know, you can easy to create VMs, Firewalls, Load Balancers on Microsoft Azure, you also can make routing path change but all of them will cost you lots of money, it depends on how many virtual devices or virtual machines that you created.

Today, I am going to show you how to build Hyper-V nested VM with multiple public IP address, you just need to pay Microsoft for one Hyper-V host with storage space and public IP addresses, you can install firewall, created lots of VMs, load balancer, control routing path, port forwarding and so on, we can use them for LAB test, POC, or even production.

Let’s follow step by step to show you how to do that.

Create Hyper-V Host VM at Azure

  1. Logon to your Microsoft Azure Account and select Create a resource.

    103118 0046 HyperVneste1 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  2. On the New page, select Windows Server 2016 VM

    103118 0046 HyperVneste2 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  3. On the Create a virtual machine page, click Basics and select your Azure Subscription to pay for this virtual machine.

    103118 0046 HyperVneste3 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  4. Select Create new under the Resource group and enter resource group name, I will recommend it as your virtual machine name, because it will easy to maintain your resources, and then click OK.

    103118 0046 HyperVneste4 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  5. Virtual Machine Name: Enter Virtual Machine Name as your resource group name.

    Region: Select Region for the virtual machine. For my case, I am using West US 2.

    Availability options: keep default setting

    Image: select Windows Server 2016 Datacenter

    Size: click change size and select the Dv3 and Ev3 VM sizes. Because we need to enable nested virtualization.

    Username: Enter login user name

    Password: Enter login password

    Confirm password: Reenter login password

    103118 0046 HyperVneste5 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

    Public inbound ports: Select Allow selected ports.

    Select in bound ports: Select RDP (3389)

    Already have a Windows license: Select Yes if you have license already.

    Confirmation: select I confirm I have an eligible Windows license with Software Assurance or Windows Server subscription to apply this Azure Hybrid Benefit.

    103118 0046 HyperVneste6 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  6. On the Create a Virtual Machine page, click Disks.

    103118 0046 HyperVneste7 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

    OS disk type: Select Premium SSD

    DATA DISKS: Select Create and attach a new disk (this storage space is for your nested VMs)

    103118 0046 HyperVneste8 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  7. On the Create a new disk page, settings as follow and then click OK.

    Disk type: Select Premium SSD

    Name: keep the default name

    Size(GiB): 4095

    Source type: None

    103118 0046 HyperVneste9 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  8. On the Create a virtual machine page, click Networking.

    103118 0046 HyperVneste10 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

    Virtual network: Select vnet if you have existing vnet, if don’t, you can keep the default settings.

    Subnet: Select subnet name if you have existing subnet, if don’t, you can keep the default settings.

    Public IP: click Create new

    103118 0046 HyperVneste11 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  9. On the Create Public IP address page, settings as follow and then click OK.

    Name: Enter Public IP address name.

    SKU: Basic

    Assignment: Static

  10. To complete Networking settings as follow:

    Network security group: Basic

    Public inbound ports: Allow selected ports

    Select inbound ports: RDP

    Accelerated networking: On

    103118 0046 HyperVneste12 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  11. On the Create a virtual machine page, click Management and keep the settings as default.

    103118 0046 HyperVneste13 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  12. On the Create a virtual machine page, click Guest config and keep the settings as default.

    103118 0046 HyperVneste14 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  13. On the Create a virtual machine page, click Tags and keep the settings as default.

    103118 0046 HyperVneste15 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  14. On the Create a virtual machine page, click Review + create and make sure Validation passed and then click Create.

    103118 0046 HyperVneste16 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

Crete Multiple IP address

  1. On the Microsoft Azure portal page, select Virtual machines.

    103118 0046 HyperVneste17 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  2. On the Virtual machines page, click GDMCALABHV1.

    103118 0046 HyperVneste18 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  3. On the GDMCALABHV1page, select Networking.

    103118 0046 HyperVneste19 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  4. On the GDMCALABHV1-Networking page, select Network Interface: gdmcalabhv1238.

    103118 0046 HyperVneste20 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  5. On the Network Interface page, select IP configurations.

    103118 0046 HyperVneste21 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  6. On the IP configurations page, select ipconfig1.

    103118 0046 HyperVneste22 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  7. Change assignment setting from Dynamic to Static, and then click Save.

    103118 0046 HyperVneste23 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  8. Go back to IP configurations page, click Add.

    103118 0046 HyperVneste24 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  9. On the Add IP configuration page, settings as follow and then click OK.

    Name: ipconfig2

    Private IP address Allocation: Static

    IP address: 10.10.1.9

    Public IP address: Enable

    IP address: click configure required settings

    103118 0046 HyperVneste25 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

    Choose public IP address: Create new

    Name: Enter name for Public IP

    SKU: Basic

    Assignment: Static and then click OK

    103118 0046 HyperVneste26 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  10. On the Add IP configuration page, click OK.

    103118 0046 HyperVneste27 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  11. Repeat Add IP configurations steps If you need more public IP addresses.

    103118 0046 HyperVneste28 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

Enable Hyper-V for Azure virtual machine

  1. Start Azure virtual machine and login.
  2. Open disk Management to partition and format for your new 4TB storage space.

    103118 0046 HyperVneste29 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  3. On the Server Manager Dashboard, click Add roles and feature.

    103118 0046 HyperVneste30 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  4. On the Before you begin page, click Next.

    103118 0046 HyperVneste31 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  5. On the Select installation type, select Role-based or feature-based installation and then click Next.

    103118 0046 HyperVneste32 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  6. On the Select destination server page, click Next.

    103118 0046 HyperVneste33 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  7. On the Select server roles page, select Hyper-V, click Add Features and then click Next.

    103118 0046 HyperVneste34 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  8. On the Select features page, click Next.

    103118 0046 HyperVneste35 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  9. On the Hyper-V page, click Next.

    103118 0046 HyperVneste36 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  10. On the Create Virtual Switches page, don’t select any interface and click Next.

    103118 0046 HyperVneste37 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  11. One the Virtual Migration page, click Next.

    103118 0046 HyperVneste38 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  12. On the Default Stores page, you can change the default location to your new 4TB storage space and then click Next.

    103118 0046 HyperVneste39 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  13. On the Confirm installation selections page, select Restart the destination server automatically if required and then click install.

    103118 0046 HyperVneste40 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  14. Login to Azure Virtual machine after it restarted.
  15. On the installation progress page, click Close.

    103118 0046 HyperVneste41 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

NAT networking with one Public IP address

We need to create Internal Virtual Switch for nested guest VMs, in general, there are two options for networking with nested virtual machines, MAC Address Spoofing and NAT networking, unfortunately, MAC Address Spoofing is not possible in a public cloud environment, so If you use Azure virtual machine network interface to be Hyper-V external virtual switch and assign to nested guest vms, the guest VMs won’t possible access to the Internet , we have no choice, we just can use NAT networking for them. If you just have one public IP address and then we can create internal virtual switch and create NAT rules via Powershell cmdlet as follow:

NNew-VMSwitch -Name "NATNetwork" -SwitchType Internal
Get-NetAdapter
New-NetIPAddress -IPAddress 192.168.100.1 -PrefixLength 24 -InterfaceIndex 14
New-NetNat -Name "NATNetwork" -InternalIPInterfaceAddressPrefix 192.168.100.0/24

103118 0046 HyperVneste42 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

You also can configure port forwarding by Powershell cmdlet as follow:

Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 443 -Protocol TCP -InternalIPAddress 192.168.100.99 -InternalPort 443 -NatName NatNetwork
Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 80 -Protocol TCP -InternalIPAddress 192.168.100.99 -InternalPort 80 -NatName NatNetwork

103118 0046 HyperVneste43 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

NAT networking with multiple public IP addresses

For the real POC or production environment, we may need more than one public IP address, it won’t easy to use Powershell cmdlet to do port forwarding or maintain them, here, I am going to show you how to use Multiple IP address for nested VMs and easy to configure port forwarding.

  1. Login to Azure Virtual Machine.
  2. Open Command prompt and run ipconfig /all and then write down the DNS IP address.
  3. Add all of IP addresses to the Azure Virtual Machine network interface, for my case are 10.10.1.8-10

    103118 0046 HyperVneste44 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  4. Re-run ipconfig /all again and you will see that all of IP addresses under the network interface.

    103118 0046 HyperVneste45 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  5. Open Hyper-V Manager tool and click Virtual Switch Manager.

    103118 0046 HyperVneste46 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  6. Select Internal and click Create Virtual Switch.

    103118 0046 HyperVneste47 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  7. Change switch name to NAT Network Switch and then click OK.

    103118 0046 HyperVneste48 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  8. Assign IP address as 192.168.100.1/24 to vEthernet (NAT Network Switch)

    103118 0046 HyperVneste49 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  9. Now, you can create vms as many as you can, they are depending on your RAM and storage space, and they won’t charge extra cost.
  10. If you would like to do port forwarding function from Public IP addresses to nested guest vms, we need to enable routing and NAT function at this Azure virtual machine.
  11. Login Azure Virtual Machine.
  12. On the Dashboard page, select Add Roles and features
  13. On the Before you begin page, click Next.
  14. On the Select installation type page, click Next.
  15. On the Select destination server page, click Next.
  16. On the Select server roles page, select Remote Access and click Next.
  17. On the Select features page, click Next.
  18. On the Remote Access page, click Next.
  19. On the Select Role services page, select Routing and click Add Features and then click Next.

    103118 0046 HyperVneste50 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  20. On the Web Server Role (IIS) page, click Next.
  21. On the Select role services page, click Next.
  22. On the Confirm installation selections page, select Restart the destination server atomically if required, click Install.

    103118 0046 HyperVneste51 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  23. On the Installation progress page, click Close.
  24. Open Routing and Remote Access tool.

    103118 0046 HyperVneste52 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  25. Right click the serve name and select Configure and Enable Routing and Remote Access.

    103118 0046 HyperVneste53 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  26. On the Welcome page, click Next.

    103118 0046 HyperVneste54 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  27. On the Configuration page, select Network address translation (NAT), click Next.

    103118 0046 HyperVneste55 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  28. On the NAT Internet Connection page, select Ethernet 2 as public Interface, click Next.

    103118 0046 HyperVneste56 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  29. On the Name and Address Translation Services page, select Enable basic name and address services, click Next.

    103118 0046 HyperVneste57 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  30. On the Address Assignment Range page, click Next.

    103118 0046 HyperVneste58 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  31. Click Finish on the Completing setup wizard page.

    103118 0046 HyperVneste59 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  32. Expand the IPv4 and select NAT.

    103118 0046 HyperVneste60 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  33. Right-click Ethernet 2 and select Properties.

    103118 0046 HyperVneste61 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  34. Select Address Pool and click Add.

    103118 0046 HyperVneste62 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  35. Enter IP addresses and mask and click OK, those IP addresses are being created with Public IP addresses at azure portal.

    103118 0046 HyperVneste63 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  36. Select Services and Ports and then click Add.

    103118 0046 HyperVneste64 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  37. Settings as follow for TCP port 443 port forwarding and then click OK.

    Description of Services: TCP443-10.10.1.10

    On this address pool entry: 10.10.1.10

    Protocol: TCP

    Incoming port: 443

    Private IP address: 192.168.100.99

    Outgoing port: 443

    103118 0046 HyperVneste65 - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

  38. On the Ethernet 2 properties page, click OK.
  39. Don’t forget to set allow TCP port 443 permissions at windows servers’ firewall and Azure NSG.

Now, you have fully control for your environment, and you also can get more public IP addresses if you need them.

Hope you enjoy this post.

Cary Sun

Twitter: @SifuSun

ca16fbd3199de5f66b829b87082fb970?s=80&d=retro&r=g - Hyper-V nested VM with multiple IP addresses Port Forwarding at Azure

Author: Cary Sun

Cary Sun has a wealth of knowledge and expertise in data center and deployment solutions. As a Principal Consultant, he likely works closely with clients to help them design, implement, and manage their data center infrastructure and deployment strategies.
With his background in data center solutions, Cary Sun may have experience in server and storage virtualization, network design and optimization, backup and disaster recovery planning, and security and compliance management. He holds CISCO CERTIFIED INTERNETWORK EXPERT (CCIE No.4531) from 1999. Cary is also a Microsoft Most Valuable Professional (MVP), Microsoft Azure MVP, Veeam Vanguard and Cisco Champion. He is a published author with several titles, including blogs on Checkyourlogs.net, and the author of many books.
Cary is a very active blogger at checkyourlogs.net and is permanently available online for questions from the community. His passion for technology is contagious, improving everyone around him at what they do.

Blog site: https://www.checkyourlogs.net
Web site: https://carysun.com
Blog site: https://gooddealmart.com
Twitter: @SifuSun
in: https://www.linkedin.com/in/sifusun/
Amazon Author: https://Amazon.com/author/carysun