Create and configure a virtual switch with Hyper-V

This article shows you how to create and configure your virtual switch using Hyper-V Manager or PowerShell. A virtual switch allows virtual machines created on Hyper-V hosts to communicate with other computers.

When you first install the Hyper-V role on Windows Server, you can optionally create a virtual switch at the same time. To learn more about virtual switches, see Hyper-V Virtual Switch.

For more information about how you can set up your networking infrastructure with Windows Server, review the Networking documentation.

Prerequisites

Before you can create and configure your virtual switch, your computer must meet the following prerequisites:

  • The Hyper-V server role must be installed.
  • Hyper-V must be enabled

Create a virtual switch

Once you complete the prerequisites, you're ready to create your virtual switch. In this section, we create a basic virtual switch by following these steps.

Here's how to create a virtual switch using Hyper-V Manager.

  1. Open Hyper-V Manager.

  2. From the Actions pane, select Virtual Switch Manager.

  3. Choose the type of virtual switch, then select Create Virtual Switch.

  4. Enter a name for the virtual switch, then perform one of the following steps.

    1. If you selected external, choose the network adapter (NIC) that you want to use, then select OK.

      You're prompted with a warning that the change may disrupt your network connectivity; select Yes if you're happy to continue.

    2. If you selected internal or private, select OK.

Management Operating System sharing

An external virtual switch allows your virtual machines to connect to an external network. You can also allow the management operating system to share the same selected network adapter. To begin, follow these steps.

Here's how to allow the management operating system to share the selected network adapter switch using Hyper-V Manager.

  1. Open Hyper-V Manager.

  2. From the Actions pane, select Virtual Switch Manager.

  3. Select the virtual switch you wish to configure, check the Allow management operating system to share this network adapter and select OK.

    You'll be prompted with a warning that the change may disrupt your network connectivity; select Yes if you're happy to continue.

Virtual LAN (VLAN) identification

You can specify the VLAN identification (ID) used by virtual machines network adapters and virtual switches. For virtual switches connected to either an external or internal network, you can specify the (VLAN) ID. The VLAN ID number is used by the management operating system and virtual machines communicating through this virtual switch.

You can also configure your virtual switch with other VLAN options, such port mode and the native VLAN ID. For these options, you need to use PowerShell and ensure the configuration is compatible with your networks configuration.

To configure the VLAN identification for the switch, follow these steps.

Here's how to specify the VLAN ID using the Hyper-V Manager.

  1. Open Hyper-V Manager.

  2. From the Actions pane, select Virtual Switch Manager.

  3. Select the virtual switch you wish to configure, check the Enable virtual LAN identification for management operating system.

    1. You can enter any VLAN ID number or leave the default, then select OK.

      You're prompted to warn you that the change may disrupt your network connectivity, select Yes if you're happy to continue.

VLAN identifiers should be consistent with your network to ensure compatibility between your computer, virtual machines, and other network devices.

NAT networking

Network Address Translation (NAT) gives a virtual machine access to your computer's network by combining the host computer's IP address with a port through an internal Hyper-V Virtual Switch.

This has a few useful properties:

  1. NAT Conserves IP addresses by mapping an external IP address and port to a much larger set of internal IP addresses.
  2. NAT allows multiple virtual machines to host applications that require identical (internal) communication ports by mapping these to unique external ports.
  3. NAT uses an internal switch -- creating an internal switch doesn't cause you to use network connection and tends to interfere less with a computer's networking.

To set up a NAT network and connect it to a virtual machine, follow the NAT networking user guide.

Next step

Now that you set up a virtual switch, here are other articles to help you continue with Hyper-V.