What is VLAN Trunk Mode in Hyper-V? #HyperV

2 min read

What is VLAN trunk mode?

Hello Folks,

In today’s blog post we will dive into VLAN trunk mode in Hyper-V 2012 R2. The same will apply to Windows Server 2016 Hyper-V and later version.

As you know, If you want to assign virtual machine network traffic to different VLANs, a network adapter that supports VLANs must be installed in the Hyper-V host and assigned to the virtual switch. You can set the VLAN ID for the virtual machine in the settings of the VM. The VLAN ID that is set in the virtual switch is the VLAN ID that will be assigned to the virtual network adapter (vmNIC) assigned to the host Operating System as showing in the following figure:


VLAN ID settings for Virtual Machine. (Image: @CharbelNemnom)

Hyper-V Virtual Switch also provides support for VLAN trunk mode. Trunk mode provides network services for a Virtual Machine with the ability to see traffic from multiple VLANs, in other words the virtual switch port receives traffic from all VLANs that you configure in an allowed VLAN list. You can also configure a switch port that is connected to a VM, but is not bound to the underlying NIC for trunk mode.

Configuring VLAN trunk mode for a (vmNIC) is not supported from Hyper-V Manager console; only a single VLAN can be configured as shown above.

How to do it?

With PowerShell, of course!

Set-VMNetworkAdapterVlan –VMName Demo –Trunk –AllowedVlanIdList 100-150 –NativeVlanId 20

In this example, “Demo” VM can send or receive traffic on any VLAN in the allowed list (100-150), and If there is no VLAN specified in the packet, the packet is treated as if it is from VLAN 20.

Note from the field

The NativeVlanId should not be within the scope listed in the AllowedVlanIdList (100-150), in other words if you set the Native VLAN ID to 110 for example, the VLAN 110 will be non functional, the VM itself will not be able to transmit tagged or untagged packets in VLAN ID 110.

Useful scenario

If you have a virtual machine that requires access to more networks than available virtual adapters, then you can enable VLAN trunk mode by using the Set-VMNetworkAdapterVlan cmdlet.

Enjoy your day!


About Charbel Nemnom 579 Articles
Charbel Nemnom is a Cloud Architect, Swiss Certified ICT Security Expert, Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems. Excellent communicator is adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design, business continuity, and cloud security.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.