The main reason for creating a Private Network on Hyper-V is to prevent a virtual machine from accessing both our physical network and our physical computer.
How to Create Private Virtual Switch in Hyper-V
After creating a Private network with Hyper-V, we need to add the created network adapter to the virtual machine. After adding a custom network adapter, virtual machines can no longer access the physical network.
However, this may change in some cases. For example, if you are going to install Pfsense with a Hyper-V in the test environment, you can complete Pfsense installation by adding an Internal Virtual Switch to the LAN and an External Virtual Switch to the WAN.
In our next articles, we will install Pfsense with Hyper-V. In our previous articles, we have examined other types of virtual networks;
Likewise, we continue to network types, and this time we will discuss the Private Virtual Network/Switch configuration.
How to Add Private Virtual Network
After adding a Custom Virtual Network adapter on Hyper-V, we will add the created network adapter to the virtual machines. We will then examine how these virtual machines can communicate with each other.
And then we’re going to test whether our physical machine can access the network card. Follow the steps below to configure Private Switch.
First, run the Hyper-V Manager virtualization program. If you haven’t installed it before, you can check out our article on Hyper-V Setup.
For example, check the Windows 10 virtual machine network adapter settings installed on Hyper-V. You can see from the image below that no Virtual Switch has added to the Windows 10 virtual machine.
To add a network adapter to a virtual machine, you must first create a new Virtual Switch from the Virtual Switch Manager settings.
Click the Virtual Switch Manager from the Actions panel.
Select Private from the VS Manager window and click the Create VS button.
Type a name for the Private Network to be created and click OK to continue.
To add the Hyper-V network adapter that you created to the virtual machine, right-click on the virtual machine.
In the Windows 10 VM settings, click the network card on the left panel, then select Switch you created from the Network Adapter section and click OK.
To test the Private Network configuration, configure two virtual machines, and test the connection between them. For example, you can use a Windows 7 virtual machine as in the image below.
Add the Private Switch to the second virtual machine.
Configure the Windows 7 TCP/IP configuration as follows. You can create the IP block here for the desired range. You do not have to fill in the default gateway address because the virtual machine will not be able to communicate with the physical network and the physical machine!
Configure the IP configuration of Windows 10 machine as follows.
Pinging from Windows 10 virtual machine to Windows 7 virtual machine is successful!
Pinging from the Windows 7 machine to the Windows 10 machine was successful!
No adapter for Hyper-V has created in the network settings of our physical computer. If we had added the Internal Switch, a vEthernet network adapter would create on the following screen.
How to Configure VLAN in Hyper-V
VLAN creation and configuration is very simple. After creating a Private Virtual Switch on Virtual Switch Manager, we need to define a VLAN ID to this network adapter. For example, a Windows 7 virtual machine that is a member of VLAN 2 will not be able to communicate with VLAN 3.
In Hyper-V, let’s take a step-by-step look at assigning virtual machines to a VLAN and testing connectivity.
Re-open the Windows 10 machine network card settings based on all the above settings. In the Virtual Machine Network Adapter window, select the VLAN ID this time and then specify the VLAN Number in the box just below it and click OK.
On the Windows 7 virtual machine, open the CMD command prompt and ping the Windows 10 VM to test the connection. The Destination host unreachable error message is reported as you see in the image below.
Pinging from the Windows 10 virtual machine to the Windows 7 virtual machine will also fail as follows.
We made Windows 10 VM a member of VLAN 2. This time, start pinging continuously on the Windows 7 virtual machine at the CMD command prompt.
As soon as you start continuous pinging, turn on the Windows 7 network adapter settings on Hyper-V. Then activate the VLAN ID option and type 2 as the VLAN Number and click OK to close the window.
As you can see in the image below, Ping will succeed as soon as the Windows 7 virtual machine assigns to VLAN 2.
Custom Virtual Switch Settings⇒ Video
To create a Hyper-V Private Network on Windows 10, you can watch the video below and also subscribe to our YouTube channel to support us!
In this article, we have examined how to configure a Custom Virtual Switch from Hyper-V virtual network types. Thanks for following us!