Skip to main content

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)

New-VMSwitch -SwitchName "LabSwitch" -SwitchType 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

Get-NetAdapter
  • Find the newly created LabSwitch interface.

  • Note the InterfaceIndex assigned to it (e.g., 49).

  • This value will be used in the next step.


๐Ÿ“ก 4. Assign a Static IP Address to LabSwitch

New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24 -InterfaceIndex 49
  • Replace 49 with 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

New-NetNat -Name "NatSwitch" -InternalIPInterfaceAddressPrefix 10.0.0.0/24
  • This enables NAT for the subnet attached to the virtual switch.

  • You can name the NAT (NatSwitch) anything you like.

  • Make sure the AddressPrefix matches the range you used in the previous step.


๐Ÿงน Optional: Remove Network Components

โŒ Remove the Virtual Switch
Remove-VMSwitch "LabSwitch"
โŒ Remove NAT Object(s)
Get-NetNat # List all existing NATs Remove-NetNat -Name "NatSwitch"

๐Ÿง  Tips

  • Attach virtual machines to the LabSwitch virtual adapter to place them on the internal NAT network.

  • VMs will use 10.0.0.1 as their gateway for internet access via NAT.

  • Use DHCP manually or statically assign IPs in the same subnet (10.0.0.x/24).