Hyper-V Virtual Switch Internal with NAT

—- UPDATE—- Be sure to check the updated blog for the powershell commands since it has changed in the newer Windows 10 and Windows Server 2016 builds

A will a go Microsoft released Windows Server 2016 TP4 and Windows 10 Build 10586. For Windows 10 it was all about nested virtualization that is a great feature which i use a lot with nano server and containers now days.

But another great feature came with that release that completely  slipped my attention and I stumbled on it exploring the New-VMSwitch powershell Cmdlets. Since that release you have the ability to set you Virtual Switch (VSwitch) not only to External, Internal and Private but also to a fourth option, which is NAT mode.

Let me explain, when you run some VM’s on your local laptop, tablet or test/dev server you probably created a Vswitch which is connected to your LAN or WIFI adapter for outside network acces or internet access. Or when you want them to talk to each other in there own subnet and you requier no internet access you have a VSwitch with a Internal Network connection type. But if you require the VM’s to have internet connection and want multiple subnets you need vlan’s.

Since not everybody has VLAN’s on a home network or you are located in a company network were you do not have controle over the network you cannot use the External Network type VSwitch to get al the VM’s on the internet or the rest of the network. Or when you are like me and are located in several different customer networks, IP’s change all the time when on DHCP or my VM’s need to change IP addresses all the time if i want to test somethings in VM’s.

All that is behind us now because we can create VSwitches for Internal Network and enable NAT on the VSwitch.

At the moment it cannot be done through the GUI. But when you create a new VSwitch with Powershell you have the NAT option for the SwitchType parameter.
So when we run the command we get a new VSwitch which is Internally connected. Don’t forget to provide a Nat Subnet Address, this is the Subnet for your VM’s:
Now we have the Virtual Network on the VSwitch, but no gateway for the VM’s in the network to connect to.  For a gateway we create a new Virtual Nic on the Vswitch.
The new NIC is created with 10.10.0.1 as IP address and connected to the new VSwitch.

And the new VSwitch is of a Internal Network type

Now connect your VM’s to the new VSwitch and configure the VM’s with an IP Address from the NATSubnet and you have a Internal Connected network with Internet and Network access.

Good luck!
Pascal Slijkerman


Leave a Comment