You dont have javascript enabled! Please enable it!

What is VLAN Trunk Mode in Hyper-V?

2 Min. Read

This article will show you how to configure the virtual VLAN settings for the traffic through a virtual network adapter in Hyper-V virtual machine.

What is VLAN trunk mode?

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 versions.

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 shown in the following figure:

VLAN ID settings for Hyper-V Virtual Machine
VLAN ID settings for Hyper-V Virtual Machine

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 virtual machine network adapter (vmNIC) is not supported from the Hyper-V Manager console; only a single VLAN can be configured as shown in the figure above.

How to do it?

With PowerShell, of course. Run the following command to set the allowed VLAN list and the Native VLAN ID:

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 parameter should NOT be within the scope listed in the AllowedVlanIdList (100-150). In other words, if you set the Native VLAN ID to 110 based on this example, then the VLAN 110 will be nonfunctional, 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.

Set-VMNetworkAdapterVlan

That’s it there you have it!

Make sure to check my recent Windows Server Hyper-V Cookbook for in-depth details about Hyper-V.

Cheers,
/Charbel

Related Posts

Previous

Free Monitoring With Veeam Task Manager For Hyper-V (TMHV) #HyperV #Veeam

Hyper-V 2012 R2: Rollup Update, August 2014 #HyperV

Next

2 thoughts on “What is VLAN Trunk Mode in Hyper-V?”

Leave a comment...

  1. Hello Eric, thanks for the feedback! The article is updated, you can copy the PowerShell command from the ‘Code Block’ in black.

Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!