#PSTip Configuring trunk mode in Hyper-V

With the introduction of Hyper-V in Windows Server 2012, the Hyper-V Extensible Switch became available providing more functionality than previous versions. One of the new features was support for VLAN trunk mode, making it possible for a virtual machine to see traffic from multiple VLANs. This might be a need for virtual machines running network services such as a reverse proxy.

Configuring trunk mode for a virtual network adapter is not supported from the Hyper-V Manager; only a single VLAN can be configured:

Hyper-V_Manager_VLAN

In order to configure trunk mode, we can use the Hyper-V PowerShell module:

Set-VMNetworkAdapterVlan –VMName DemoVM –Trunk –AllowedVlanIdList 1000-1050 –NativeVlanId 1000

The above example will enable the virtual machine DemoVM to send and receive traffic on VLAN 1000 to 1050. If no VLAN is specified in the network packet, it will be processed on VLAN 1000.

About the author: Jan Egil Ring

Jan Egil works as a Lead Architect on the R&D Team at Crayon, Norway. He mainly works with automation, and has a strong passion for PowerShell. Products and services he works with includes Microsoft infrastructure products such as Windows Server, System Center and Microsoft Azure. He is a multiple-year recipient of Microsoft Most Valuable Professional Award for his contributions in the Windows PowerShell and Cloud & Datacenter Management technical communities. He speaks regularly at user groups and conferences, such as Nordic Infrastructure Conference (NIC), PowerShell Conference Europe and PowerShell Summit. He is a co-founder of the Norwegian Microsoft Technology User Group (MTUG), which is an association of local MTUG user groups in Norway. He is also co-organizing the MTUG Script Club which focuses mainly on PowerShell. You can follow him on Twitter @JanEgilRing.

Related Posts

%d bloggers like this: