Send trunk directly to vm in HyperV 2012

Using the PowerShell Set-VMNetworkAdapterVlan cmdlet, you can turn on trunk mode on the virtual NIC. I don't think there is an equivalent GUI option for this.

Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList "100,101" -VMName "VmName" -VMNetworkAdapterName "TrunkNic" -NativeVlanId 1
  • -Trunk turns on trunk mode, which leaves the VLAN tags intact.
  • -AllowedVlanIdList specifies which VLAN's to allow the guest to use. This parameter is mandatory in trunk mode. If you have a largeish number of VLANs, you also can use ranges like -AllowedVlanIdList "1-4000"
  • -NativeVlanId is required, too. It specifies which VLAN outgoing untagged packets belong to. I think that it also has strips off the VLAN tag for incoming packets on that VLAN. Or something like that. I remember that there was a weird behavior here that I completely sidestepped by just setting this to an unused, blackholed VLAN and not using the untagged interface in the guest, because that was easier to configure and seemed less fragile to me.