Introduction / Why This Is Needed
The Virtual Switch in Hyper-V is a key component that enables network communication between virtual machines (VMs), the host system, and the external network. Proper switch configuration resolves most network issues in a virtual environment—from lacking internet access to needing to isolate traffic between servers. After completing this guide, you will be able to create and configure three switch types, understand their purposes, and troubleshoot common issues.
Prerequisites / Preparation
Before you begin, ensure the following conditions are met:
- Operating System: Windows 10 Pro/Enterprise/Education or Windows 11 of equivalent editions. Home editions do not support Hyper-V.
- Installed Hyper-V Role: Open "Control Panel" → "Programs and Features" → "Turn Windows features on or off". The "Hyper-V" checkbox must be selected. Alternatively, in an administrative PowerShell:
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart. - Administrator Privileges: All operations for creating and configuring switches require running PowerShell or Hyper-V Manager as an administrator.
- Physical Network Adapter: To create an External switch, you must have at least one working physical network interface (Ethernet or Wi-Fi).
Step-by-Step Guide
Step 1: View Current Configuration and Adapters
First, understand what already exists in your system. Launch an administrative PowerShell and run the command to view all virtual switches:
Get-VMSwitch | Format-List Name, SwitchType, NetAdapterInterfaceDescription
Example output:
Name : ExternalSwitch
SwitchType : External
NetAdapterInterfaceDescription : Intel(R) Ethernet Connection I219-V
Name : InternalNetwork
SwitchType : Internal
NetAdapterInterfaceDescription :
Pay attention to SwitchType and NetAdapterInterfaceDescription for external switches.
Also, find the exact names of your physical network adapters:
Get-NetAdapter | Where-Object {$_.Status -eq "Up"} | Select-Object Name, InterfaceDescription, Status
Note the Name of the required adapter, such as Ethernet or Wi-Fi.
Step 2: Create an External Virtual Switch
An External switch provides VMs with direct access to the physical network, as if they were separate computers on your LAN. They receive IP addresses from the same DHCP server as the host.
⚠️ Important: One physical adapter can be bound to only one external switch. If a switch already exists, the
New-VMSwitchcommand will fail.
Via PowerShell (recommended):
New-VMSwitch -Name "GuestInternet" -NetAdapterName "Ethernet" -AllowManagementOS $true
-Name "GuestInternet"— sets the switch name. Use letters and digits without spaces for reliability.-NetAdapterName "Ethernet"— specifies the physical adapter name from Step 1.-AllowManagementOS $true— critically important parameter.$truemeans the host system (Windows) will also use this switch for its network connection. If you are creating a switch only for VMs and want to keep the host's network on a different adapter, set$false. However, the host will then lose connectivity through this adapter.
Via Graphical Interface (Hyper-V Manager):
- Open "Hyper-V Manager".
- In the right menu, select "Virtual Switch Manager".
- Click "Create Virtual Switch" → "External".
- In the "Name" field, enter a descriptive name (e.g.,
External-Net). - Under "Connection to", select the required physical adapter from the list.
- Must leave the checkbox "Allow management operating system to use this virtual switch" checked if you want the host to have network access through it.
- Click "OK". The system may restart network services and briefly interrupt the connection.
Step 3: Create an Internal or Private Switch
These types have no access to the physical network.
- Internal: The network is available only between VMs and the host system. The host sees this switch as a separate network adapter. Ideal for test environments or when VMs need to communicate with services on the host.
New-VMSwitch -Name "LabNetwork" -SwitchType Internal
After creation, configure a static IP on the host's virtual adapter (viancpa.cpl) and on the VM adapters in the same subnet (e.g., 192.168.100.1 and 192.168.100.2/24). - Private: The network is available only between virtual machines. The host does not see this switch. Used to create completely isolated clusters or tests where the host should not intervene.
New-VMSwitch -Name "IsolatedNetwork" -SwitchType Private
Configure IPs only on the VM adapters.
Step 4: Assign a Switch to a Virtual Machine
- In Hyper-V Manager, select the required VM from the list.
- Right-click → "Settings" (or "Properties" in older versions).
- In the left menu, select "Advanced" (or "Network Adapter" in simple mode).
- In the "Virtual switch" dropdown, select the created switch (e.g.,
GuestInternet). - Click "OK".
- Restart the virtual machine so the network adapter reinitializes with the new settings.
Step 5: Verify Network Operation Inside the Virtual Machine
Start the VM and perform checks:
- Open Command Prompt or PowerShell inside the VM.
- Check for a network adapter and IP acquisition:
You should have an adapter with an IP address (for an external switch—from your DHCP, for internal/private—static, which you configured).ipconfig /all - Check connectivity with the host (for Internal/Private):
ping <host_IP_address_in_this_network> - Check internet access (for External):
If pings work but sites don't open, check DNS settings (ping 8.8.8.8ipconfigshows DNS servers).
Result Verification
The main indicator of successful configuration is that the VM receives a correct IP address and can communicate in the required direction:
- For an External switch: The VM should obtain an IP from your router/DHCP server and have access to the internet and local network.
- For an Internal switch: The VM and host should see each other (check
pingby the IP set on the host's virtual adapter). The host's name in this network is usuallyHostorWindows. - For a Private switch: Two or more VMs connected to the same Private switch should be able to "ping" each other.
Also, on the host, you can run in PowerShell:
Get-VMNetworkAdapter -VMName "YourVMName" | Select-Object -ExpandProperty IPAddresses
This will show the IP addresses that Hyper-V sees for a specific VM's adapter.
Possible Issues
Error: "Failed to add virtual switch... Adapter already in use"
This means the selected physical adapter is already bound to another external switch. Solution:
- Remove or reconfigure the existing switch:
Remove-VMSwitch -Name "OldSwitch"(or via GUI). - If the adapter is used by the host (e.g., for Wi-Fi), create an Internal/Private switch or disable
-AllowManagementOSfor the External switch, but then the host will lose network access through that adapter.
VM does not receive an IP address (DHCP)
- Ensure the physical adapter bound to the External switch has access to a DHCP server (try releasing/renewing from the host with
ipconfig /releaseandipconfig /renew). - Verify that in the VM's Hyper-V settings, the correct switch is selected for the network adapter.
- Inside the VM, restart the DHCP client service:
net stop dhcp && net start dhcp(cmd) orRestart-Service Dhcp(PowerShell).
No connectivity, but IP is present (for External)
Most often, the issue is the Windows Firewall on the host or inside the VM. When an External switch is created with -AllowManagementOS $true, host traffic is filtered. Try temporarily disabling the host firewall for testing. Also check if antivirus or corporate security policies are blocking traffic.
Host "loses" network after creating External switch
This happens if the "Allow management operating system to use this virtual switch" checkbox was unchecked (-AllowManagementOS $false) during creation. The host will create a new virtual adapter, but the physical adapter remains "clean". Solution: either create a new External switch with $true (after removing the old one), or configure a static IP on the host's virtual adapter that appears in ncpa.cpl (it will have a name like "vEthernet (SwitchName)") and set up routing.