Create a Virtual Internal VS with NAT Network in Hyper-V
โ๏ธ Step-by-Step Instructions
This guide walks you through creating aย Hyper-V Internal Virtual Switch with NAT support for use in labs or test environments โ useful for setting up isolated virtual networks.
๐ง 1. Open PowerShell as Administrator
All commands below require elevated privileges.
๐ 2. Create a New Virtual Switch (Internal)
-
This creates an Internal Hyper-V virtual switch named
LabSwitch. -
The internal switch allows communication between host and virtual machines but not to the internet directly.
๐ 3. Get the Interface Index of the New Adapter
-
Find the newly created LabSwitch interface.
-
Note the
InterfaceIndexassigned to it (e.g.,49). -
This value will be used in the next step.
๐ก 4. Assign a Static IP Address to LabSwitch
-
Replace
49with the actual InterfaceIndex from step 3. -
You can use any private IP subnet (e.g.,
192.168.100.1/24,172.16.0.1/24, etc.).
๐ 5. Create a NAT Network
-
This enables NAT for the subnet attached to the virtual switch.
-
You can name the NAT (
NatSwitch) anything you like. -
Make sure the
AddressPrefixmatches the range you used in the previous step.
๐งน Optional: Remove Network Components
โ Remove the Virtual Switch
โ Remove NAT Object(s)
๐ง Tips
Attach virtual machines to the LabSwitch virtual adapter to place them on the internal NAT network.
VMs will use
10.0.0.1as their gateway for internet access via NAT.Use DHCP manually or statically assign IPs in the same subnet (
10.0.0.x/24).