Hyper-V Creating a NAT Network and vSwitch

KB ID 0001384

Problem

I’m without access to all my test equipment at the moment, so when I needed to do some testing, I thought I’d use Hyper-V on my new work laptop. I needed to ‘knock up’ a quick vSwitch that would NAT my test machines, to my laptops connected NIC.

Solution

Open an administrative PowerShell window, and execute the following three commands. Note: You can change the values in RED to suit your own requirements, or leave them as they are to copy my network setup.

New-VMSwitch -SwitchName "NAT-Switch" -SwitchType Internal

New-NetIPAddress -IPAddress 192.168.200.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NAT-Switch)"

New-NetNAT -Name "NAT-Network" -InternalIPInterfaceAddressPrefix 192.168.200.0/24

Hyper V Nat Network Switch

As far as Hyper-V is concerned that’s it! Now simply connect your virtual machines to the new switch.

Connect Hyper V Guest to NAT Switch

Remember you have a NAT switch, it’s not doing DHCP, you will need to assign your virtual machines static IP addresses, though you can of course configure a DHCP server on one of your virtual machines.

Hyper-V IP Settings NAT

 

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

Submit a Comment

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