# 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)

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-new-vmswitch--switch"><div class="overflow-y-auto p-4" dir="ltr">`New-VMSwitch -SwitchName "LabSwitch" -SwitchType Internal`</div></div>- 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

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-netadapter"><div class="overflow-y-auto p-4" dir="ltr">`Get-NetAdapter`</div></div>- 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

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-new-netipaddress--ip"><div class="overflow-y-auto p-4" dir="ltr">`New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24 -InterfaceIndex 49`</div></div>- 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

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-new-netnat--name-%22na"><div class="overflow-y-auto p-4" dir="ltr">`New-NetNat -Name "NatSwitch" -InternalIPInterfaceAddressPrefix 10.0.0.0/24`</div></div>- 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

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-remove-vmswitch-%22lab"><div class="overflow-y-auto p-4" dir="ltr">`Remove-VMSwitch "LabSwitch"`</div></div>##### ❌ Remove NAT Object(s)

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-netnat-%23-list-al"><div class="overflow-y-auto p-4" dir="ltr">`Get-NetNat          # List all existing NATsRemove-NetNat -Name "NatSwitch"`</div></div>---

> 🧠 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`).