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

Hello Folks,

In today’s blog post we will dive into VLAN trunk mode in Hyper-V 2012 R2.

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-ID01

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

What is VLAN trunk mode?
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.

So, how to do it?

With PowerShell, of course Smile

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

In the 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 case
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!

Cheers,
/Charbel

About Charbel Nemnom 298 Articles
Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator 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 and virtualization.

1 Trackback / Pingback

  1. How to pass DHCP / PXE through to a virtual machine - Flo's Datacenter Report

Leave a Reply