In this tutorial, I will tell you how to create a virtual switch on Hyper-V and tell you the difference between the 3 types.
What is a virtual switch
A virtual switch is a virtual switch created on Hyper-V, which allows virtual adapters of virtual machines (but not only) to have access to a network. Depending on the type of virtual switch (which we will see below) access to the network is different.
A virtual switch can be attached to a physical network card (ethernet, wi-fi or teaming) of the Hyper-V host server, in this case, the physical card becomes “unusable” by the host, because it is “transforming” “in switch, but don’t panic, to continue to have access to the network with the host, it is possible to create a virtual network card attached to the Hyper-V host which will be connected to the virtual switch.
To summarize, a virtual switch is a virtual network device (switch) on Hyper-V which allows virtual cards to access the network.
Types of virtual switches on Hyper-V
On Hyper-V, it is possible to create 3 different types of switches:
Now I suggest you to see a more detail each switch.
The external type switch is mainly characterized by the fact that it is linked to a physical network card of the Hyper-V host. If the physical network card is connected to a device (switch), the virtual network cards connected to this switch will have access to the “physical” network.
The external switch is used to connect the virtual machines to the same network as the Hyper-V host, if a DHCP server is present, the virtual machines will have an assigned IP address.
At the beginning of the article, I explained to you, that the assignment of a physical card to an external switch prevents its use by the host, to overcome this problem in the case where only one physical card is available on the Hyper-V host or that you have created a “teaming” with all the physical cards of the host, it is possible when creating the external switch, to create a virtual network card connected to this switch. To do this when creating the external switch, you must check the option box: Allow the operating system to share this network card, which will have the effect of creating a virtual network card for the Hyper-V host .
In order to illustrate the above explanations, I suggest you see several screenshots that I will explain to you.
On the screenshot below, we can see that an external switch is configured, that it is attached to the physical card (Realtek PCIe Gbe Family Controller) and that the Allow the operating system to share this network card box is checked.
We are going to see the network connections on the Hyper-V host. On the screenshot below, we see the Realtek network card which is activated 1 as well as a virtual network card named vEthernet (Virtual Switch External) 2.
If we look at the properties of the physical card, we can see that it does not have an IP configuration because the IPv4 and IPv6 protocols are not activated, but that the Hyper-V virtual switch option is active.
If we do the same thing with the virtual card which is linked to the switch, we can see that it has an IP address, which means that the IP protocols are active on the card, we also see that the Virtual switch option for Hyper-V is not checked.
In this illustration, the Hyper-V host computer has an external switch attached to a physical network adapter, it has a virtual network adapter connected to the external switch which provides it with a connection to the local network.
Virtual machines that will have a virtual network adapter connected to the same external switch will have access to the same network as the host, so they will be able to communicate with each other.
A physical network adapter cannot be linked to more than one external switch.
The internal switch is “quite similar” to the external switch with the main difference that the latter is not bound to a physical adapter on the Hyper-V host and therefore virtual machines do not have enough on the network.
When creating an internal switch, a virtual card is created on the Hyper-V host which is connected to it, this allows from the Hyper-V server to access the network to this network and for example to take the hand on virtual machines.
This type of switch is useful if you want to create isolated labs while still being able to take control from the Hyper-V host.
To communicate the Hyper-V host and the virtual machines connected to the internal switch, it is necessary to configure an IP address on the same network on the different network cards.
A private switch is a virtual switch that completely isolates the virtual machines, there is no network switching between the Hyper-V host and the virtual machines.
This type of switch makes it possible to carry out restoration tests, for example in an isolated environment without risk for production.
Create a virtual switch on Hyper-V
I have already covered this subject in a tutorial : Hyper-V: Create a virtual switch
The procedure is the same for Windows Server and Windows 10.
- External switch: linked to a physical card of the Hyper-V host and allows access to the network.
- Internal switch: isolates the virtual machines but allows network switching between the Hyper-V host and the virtual machines.
- Private Switch: Completely isolates the network from virtual machines.