This article will explore how to configure and use Private Virtual Switch in Microsoft Hyper-V virtualization software running on Windows 10 or Windows 11 operating system to restrict the connection of specific virtual machines to locations you do not want them to access.
How to Create a Private Virtual Switch in Hyper-V
The main reason for creating a Private Virtual Switch on Hyper-V is to prevent a virtual machine from accessing our physical network and computer. After making the private network, we must add the created network adapter to the virtual machine. After adding the adapter, virtual machines can no longer access the physical network.
However, this may change in some cases. For example, suppose you will install Pfsense with a Hyper-V in the test environment. In that case, you can complete the Pfsense installation by adding an Internal Virtual Switch to the LAN and an External Virtual Switch to the WAN.
In the following articles, we will install Pfsense with Hyper-V. In our previous articles, we have examined other types of virtual networks;
You can also watch the video tutorial on the topics mentioned above on our YouTube channel;
Likewise, we continue to discuss network types; 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.
Step 1
First, run the Hyper-V Manager virtualization program. If this is your first installation, you can check out our article on Hyper-V Setup.
Step 2
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 been added to the Windows 10 virtual machine.
Step 3
To add a network adapter to your virtual machine, create a new Virtual Switch from the Virtual Switch Manager settings. This initial step is crucial to establishing a virtual machine’s network connection.
Click the Virtual Switch Manager from the Actions panel.
Step 4
Select Private from the VS Manager window and click the Create VS button.
Step 5
Type a name to create the private network and click OK to continue.
Step 6
To connect the Hyper-V network adapter you created to your virtual machine, right-click on the VM and select the correct option.
Step 7
In the Windows 10 VM settings, click the network card on the left panel, select the Switch you created from the Network Adapter section, and click OK.
Step 8
To test the Private Network configuration, configure two virtual machines and test the connection between them. For example, as in the image below, you can use a Windows 7 virtual machine.
Add the Private Switch to the second virtual machine.
Step 9
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 cannot communicate with the physical network or device!
Step 10
Configure the IP configuration of the Windows 10 machine as follows.
Step 11
Pinging from Windows 10 virtual machine to Windows 7 virtual machine is successful!
Step 12
Pinging from the Windows 7 machine to the Windows 10 system was successful!
Step 13
We did not configure any adapters for Hyper-V in the network settings of our physical computer. If we had added the internal Switch here, a vEthernet network adapter would have been created, as in the image below.
How to Configure VLAN in Hyper-V
VLAN creation and configuration are effortless. After creating a Private Virtual Switch on Virtual Switch Manager, we must define a VLAN ID for this network adapter. For example, a Windows 7 virtual machine member of VLAN 2 cannot communicate with VLAN 3.
In Hyper-V, let’s look at assigning virtual machines to a VLAN and testing connectivity.
Step 1
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, specify the VLAN Number in the box just below it, and click OK.
Step 2
Open the CMD command prompt on the Windows 7 virtual machine and ping the Windows 10 VM to test the connection. The Destination host unreachable error message is reported in the image below.
Step 3
Pinging from the Windows 10 virtual machine to the Windows 7 virtual machine will also fail as follows.
Step 4
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.
When you start continuously pinging, turn on the Windows 7 network adapter settings on Hyper-V. Then activate the VLAN ID option, 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 is assigned to VLAN 2.
Video
To create a Hyper-V Private Network on Windows 10, watch the video below and subscribe to our YouTube channel to support us!
Conclusion
This article examined how to configure a Custom Virtual Switch from Hyper-V virtual network types. Thanks for following us!