How to create a nat network on windows 10 for virtual machine network access

I recently purchased a Dell precision 7720. With 32 GB of ram, I had enough resources to build a small VM lab. I installed 5 Virtual machines. It worked really well. I noticed a new feature as well. There is a Default Vswitch created in Hyper-V. This network gets assigned a default network and subnet. This is special because this vswitch is NAT enabled and cannot be deleted!

This turns out to be a good thing. You are able to give your Virtual machines internet connectivity to the outside world without consuming a shared External Network Adapter. It turns out this particular Vswitch is not special. You don’t even have to use it.

In fact, I outline below how to create a NAT network below, that has a subnet I am more comfortable with. Three steps is all you need.  If you need to fix your “default switch”, just skip step one with the command Get-NetIPAddress | fl interfacealias,interfaceindex. Use your interface index to begin with Step 2. If you try to remove the default switch from Hyper-V, the Vswitch should reset. You can remove the switch from Device Manager, but you will still see the switch in Hyper-V. this is working as designed. I think a restart may be required to restore functionality after you remove the network.

This is step 1

  • Create Internal Hyper-V network V-Switch (take note of InterfaceIndex. You need to use it in step 2)

New-VMSwitch -Switchname “myswitch” -switchtype internal -verbose

Now Step 2

  • Associate IP to Vswitch to serve as gateway and IP address to adapter

New-netipaddress -ipaddress -prefixlegnth 24  -interfaceindex 27 -verbose

Then Step 3

  • Define network and subnet for NAT

New-netnat -name NatNetwork -InternalIPInterfaceAddressPrefix -verbose

Step 4

  1. Get VM connected to VM switch in step 1

Get-VM | Get-VmNetworkAdapter | Connect-VmNetworkAdapter -switchname “myswitch”

Final point

To remove the network simply run Remove -NetNat -name “Natnetwork”

Just a quick Note on steps I used to fix my box for a situation i was setting up.


I hope this helps



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s