Configure Hyper-V NAT Virtual Switch and NAT Forwarding

Configure Hyper-V NAT Virtual Switch and NAT Forwarding

Windows Server 2016 and Windows 10 adds the native ability for a NAT forwarding Hyper-V switch. This is really handful software-defined networking (SDN) or even lab environment. By default, there is no inbound access from the LAN to the virtual machines that are connected to an NAT-enabled (Internal) virtual switch. And you might want to access isolated virtual machines in your lab through RDP with your laptop. Actually, the old way was to create a specific virtual machine in this lab to act as a gateway. You can find more information in Microsoft documentation.

To create a new NAT switch using 172.16.0.1/16 subnet on your Hyper-V host, use these PowerShell commands:

Of course, you will need to map your virtual machine network adapter to the right virtual switch and assign an IP in this subnet to your virtual machine and set 172.16.0.1 address as the default gateway. Then if you want to access this virtual machine through RDP for example, run this PowerShell command:

With this configuration, you will be able to connect to your isolated lab virtual machine (IP: 172.16.0.10) through your host “public” IP and the port 50000 using RDP without additional VM to configure.

Note
You will need to configure the firewall of the Hyper-V host (and even maybe your router if pointing to a public address) accordingly to the NAT mapping rule.
Warning
Multiple NAT networks are not supported.

One thought on “Configure Hyper-V NAT Virtual Switch and NAT Forwarding

Leave a Reply

Your email address will not be published. Required fields are marked *