Virtual LAN domains isolate the network traffic of servers/computers from other computers. Hyper-V also provides...
the VLAN domain concept, where you can isolate VM traffic from other VMs connected to the same Hyper-V virtual switch. Although you can create a separate Hyper-V virtual switch and then connect only the VMs that require isolation, you can avoid the overhead of creating and managing another VM with the Hyper-V VLAN concept.
You can configure Hyper-V virtual switches in either Access mode or Trunk mode. It's important to note that you can only configure external and internal Hyper-V virtual switches in Trunk mode or Access mode.
You can use PowerShell cmdlets or Hyper-V Manager to query and assign VLAN IDs to the Hyper-V virtual switch. However, it's easier to use Hyper-V Manager because all you need to do is open the property page of a Hyper-V virtual switch, tick the Enable virtual LAN identification for management operating system option and then specify the VLAN ID in the VLAN ID box.
Once you've configured Hyper-V virtual switches in either Access mode or Trunk mode, the next step is to configure VMs to use a VLAN ID. To configure VMs with VLAN IDs, go to the property page of a VM, select the virtual network adapter -- which is connected to the Hyper-V virtual switch -- tick the Enable Virtual LAN Identification option and then specify the VLAN ID in the VLAN ID box.
You can assign a VLAN ID on the property page of a VM using Hyper-V Manager, but using the site-VMNetworkAdapterVLAN PowerShell cmdlet can help you configure VLAN IDs for multiple VMs. To configure VLAN IDs for a particular VM using PowerShell, execute the PowerShell command below:
Set-VMNetworkAdapterVLAN –VMName SQLVM –Access –VLANID 100
This command configures SQLVM to use VLAN ID 100 and tags the outbound traffic this VM sends with VLAN ID 100. The VMs configured with the same VLAN ID -- 100, in this case -- will be able to receive the traffic from SQLVM. Other VMs will just drop the traffic.
If you want to configure the VLAN ID for several VMs, create a text file that -- assuming VM names are mentioned in the C:\Temp\VMFile.txt file -- contains VM names and then use the PowerShell script below:
ForEach ($VMName in GC C:\Temp\VMFile.TXT)
Set-VMNetworkAdapterVLAN –VMName $VMNAme –Access –VLANID 100
Explore different use cases for Hyper-V virtual switch extensions
Navigate improvements to Windows Server 2016 Hyper-V Manager
Dig Deeper on Microsoft Hyper-V management
Related Q&A from Nirmal Sharma
There isn't a set number of virtual processors you should configure for a Hyper-V VM, but there are steps you can take to ensure your workloads ... Continue Reading
VHD File Set -- a file format new to Windows Server 2016 -- is helpful for IT administrators using guest clusters. Get up to speed on the basics and ... Continue Reading
Download and install Microsoft Virtual Machine Converter to gain access to several PowerShell commands that enable VMware VMDK to Hyper-V VHDX ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.