Introduction
Hyper-V is Microsoft's hypervisor for virtualization on Windows and Windows Server. Network configuration is a critical step that determines whether virtual machines (VMs) can access the internet, communicate with the host system, and interact with other VMs. This guide will detail how to create and configure Hyper-V virtual switches (external, internal, and private) and connect VMs to them. Upon completion, you will have a fully functional network infrastructure for your VMs.
Requirements / Preparation
Before you begin, ensure that:
- You have Windows 10 Pro/Enterprise, Windows 11 Pro/Enterprise, or Windows Server 2019/2022 installed.
- The Hyper-V role is enabled. To verify:
- On client Windows: open Control Panel → Programs and Features → Turn Windows features on or off and confirm the Hyper-V checkbox is selected.
- On Windows Server: in PowerShell, run
Get-WindowsFeature -Name Hyper-V(it should be installed).
- You have administrator privileges.
- To create an external switch, a physical network adapter (e.g., Ethernet or Wi-Fi) that is not used by other virtual networking services (VPN, Docker, etc.) is required.
- It is recommended to temporarily disable antivirus or firewall software that might block the creation of virtual adapters.
Step 1: Opening Hyper-V Manager
Hyper-V Manager is the graphical management console. Launch it:
- Click Start and type Hyper-V Manager, then select the application.
- Or press Win + R, type
virtmgmt.msc, and press Enter. - If Hyper-V is not installed, you will see an error. In this case, return to the Requirements section and install the role.
A Hyper-V Manager window will appear with a list of hosts (usually your local computer).
Step 2: Creating an External Virtual Switch
An external switch allows VMs to directly use a physical network adapter, gaining access to the local network and the internet.
- In the Actions menu (on the right), select Virtual Switch Manager.
- In the Virtual Switches section, click Create Virtual Switch.
- Select the External type and click Next (or Create in older versions).
- In the Name field, enter a descriptive name, e.g.,
ExternalSwitch. - In the Connection to section, select a physical network adapter from the list (e.g.,
EthernetorWi-Fi).⚠️ Important: If the adapter is already in use (e.g., for VPN or teamed connections), you may get an error. Select a free adapter or free up the current one.
- Leave the options:
- Allow management operating system to share this network adapter (allows the host to use this switch).
- Enable virtual LAN identification (recommended).
- Click OK. A warning about restarting the adapter will appear—agree.
- After successful creation, the new external switch will appear in the switch list. Close the manager.
In Windows Network Connections, a new adapter named vEthernet (ExternalSwitch) will appear.
Step 3: Creating an Internal or Private Switch
An internal switch provides communication between VMs and the host system. A private switch allows communication only between VMs (the host does not participate).
- Open Virtual Switch Manager again.
- Click Create Virtual Switch.
- For an internal switch, select the Internal type. For a private switch, select Private.
- Enter a name, e.g.,
InternalSwitchorPrivateSwitch. - Click OK.
- For an internal switch: on the host, an adapter named
vEthernet (InternalSwitch)will appear in Network Connections. It will need to be configured manually (e.g., assign IP 192.168.1.1) so the host and VMs can communicate. - For a private switch, no adapter is created on the host—only VMs connected to it will see each other.
Step 4: Configuring Virtual Machine Network Adapters
Now connect your VMs to the created switches.
- In Hyper-V Manager, select a virtual machine from the list.
- Click Settings (or right-click → Settings).
- In the left pane, select Add Hardware.
- From the list, select Network Adapter and click Add.
- In the Network Adapter section:
- In the Virtual Switch field, select the created switch from the list (e.g.,
ExternalSwitchfor internet access). - You can enable Enable virtual LAN identification (usually on by default).
- In the Virtual Switch field, select the created switch from the list (e.g.,
- Click OK.
- Repeat for other VMs, assigning the appropriate switches:
- For internet access — external.
- For communication with the host — internal.
- For isolation between VMs — private.
- If multiple networks are needed (e.g., internet and an internal network), add multiple network adapters in the VM settings and select different switches for each.
Step 5: Verifying Network Connectivity
After configuration, verify that the network works.
- Start the virtual machine.
- Inside the VM, open Command Prompt or PowerShell.
- Check IP address acquisition:
- Run
ipconfig /all. - For an external switch, the IP should be from your local network (e.g., 192.168.1.100), with a gateway and DNS.
- For internal/private switches, the IP will be from the range you configure (e.g., 192.168.2.10).
- Run
- Check internet access (for external switch):
- Run
ping 8.8.8.8(Google DNS). If you get replies—internet works. - Try opening a website in the VM's browser.
- Run
- Check communication with the host (for internal switch):
- On the host, find the IP address of the
vEthernet (InternalSwitch)adapter viaipconfig(e.g., 192.168.1.1). - From the VM, ping that address:
ping 192.168.1.1.
- On the host, find the IP address of the
- Check communication between virtual machines (for internal/private switches):
- Find the IP addresses of other VMs connected to the same switch.
- Ping them from the current VM.
Result Verification
After all steps, the network should function correctly:
- External switch: VMs have access to the internet and local network, receiving IPs via DHCP from your router.
- Internal switch: The host system and all VMs connected to it can exchange packets (e.g., the host can ping VMs and vice versa). For internet access via the host, Internet Connection Sharing (ICS) or routing may need to be configured.
- Private switch: Only VMs connected to the same private switch can see each other. The host does not participate.
If all ping tests pass and resources are accessible—configuration is successful.
Potential Issues
1. Error when creating external switch: "Failed to bind virtual switch to physical adapter"
- Cause: The physical adapter is in use by other software (VPN, VMware, VirtualBox) or is part of a teamed connection.
- Solution:
- Disable conflicting programs (e.g., disconnect the VPN client).
- Select a different free physical adapter.
- Ensure the adapter is not disabled in "Network Connections".
2. Virtual machine does not receive an IP address (DHCP)
- Cause:
- For external switch: DHCP server on the physical network is unavailable or blocking requests.
- For internal switch: No DHCP server or static IP configured on the host's virtual adapter.
- Solution:
- External: Check that the physical network has DHCP (usually the router). Restart the VM or run
ipconfig /releasefollowed byipconfig /renewinside it. - Internal: On the host, configure a static IP on the
vEthernet (InternalSwitch)adapter (e.g., 192.168.1.1/24). In the VM, configure a static IP in the same subnet (e.g., 192.168.1.2) and gateway 192.168.1.1 if internet access via the host is needed.
- External: Check that the physical network has DHCP (usually the router). Restart the VM or run
3. No internet access from VM, although IP is obtained
- Cause: Incorrect gateway or DNS servers, or a firewall blocking traffic.
- Solution:
- Check IP settings in the VM (
ipconfig /all): the gateway should match your router's address on the physical network (e.g., 192.168.1.1). DNS can be set to 8.8.8.8. - Temporarily disable the firewall on the host and in the VM for testing.
- Ensure the physical adapter bound to the external switch has internet access.
- Check IP settings in the VM (
4. IP address conflicts
- Cause: Two devices on the same network (e.g., two VMs or a VM and the host) have the same IP.
- Solution:
- Check IP addresses of all devices on the network segment (via
arp -aor viewing DHCP leases on the router). - Change duplicate addresses to unique ones. For static IPs, assign manually; for DHCP, ensure the range excludes static addresses.
- Check IP addresses of all devices on the network segment (via
5. Internal switch not working (host cannot see VM)
- Cause: The
vEthernet (InternalSwitch)adapter on the host is disabled or not configured. - Solution:
- Open Network Connections on the host, locate
vEthernet (InternalSwitch), right-click → Enable. - Configure the IP address: open the adapter's properties, select IPv4, set a static IP (e.g., 192.168.1.1) and subnet mask 255.255.255.0.
- In the VM connected to the same internal switch, configure an IP in the same subnet (e.g., 192.168.1.2) and gateway 192.168.1.1 if internet access via the host is needed.
- Open Network Connections on the host, locate
6. Poor network performance
- Cause: Outdated drivers, missing Integration Services, or incorrect switch settings.
- Solution:
- Install the latest Windows updates and drivers for the physical network adapter.
- Inside the VM, install Integration Services (in the VM's menu: Action → Insert Integration Services Setup Disk).
- For the external switch, ensure the selected physical adapter is high-speed (Gigabit Ethernet) and that the cable/router are not bottlenecks.