Powershell – Hyper-V guest loses network access when virtual switch port is in trunk mode

hyper-vhyper-v-server-2012-r2powershellvlan

I have guest VM on a Windows Server 2012 R2 machine running Hyper-V. Currently, the guest is using the native vlan (vlan ID 1). I can communicate with the guest from the host and from the network. However, the guest is a Zebra/Motorola VX9000 wlan controller that will also need to handle traffic on vlan IDs 10 and 15. The switch port used by the host is untagged on vlan 1, and I updated the port to also be tagged on vlans 10 and 15. I also issue the following command via powershell:

Set-VMNetworkAdapterVlan -VMName MyGuest -Trunk -AllowedVlanIdList "10,15" -NativeVlanId 1

Unfortunately, after I execute this command I lose my ability to communicate with the guest. If I open the Hyper-V console for the guest, it does not have any network access. Trying to ping the guest from the host or other locations on the network results in a Destination host unreachable message.

I can "fix" it by returning the adapter to untagged mode:

Set-VMNetworkAdapterVlan -VMName MyGuest -Untagged

Now I can communicate with the guest again, but this doesn't really solve anything. I still need this guest to be able to handle traffic on vlans 10 and 15.

I don't understand why this happens. Untagged packets were vlan ID 1 before switching to trunk mode. Shouldn't it still be that way now? How can I get this guest to communicate on all of the vlans that I need?

The best I get from error message I see when pinging is similar to what I would see if there were no route. Do I need to issue a separate command to create a route for these networks after setting the port as a trunk (perhaps on the host)?

Best Answer

I only have a couple VMs set up this way and they also did not talk on the native VLAN. What we did to solve this was to set the native VLAN to something unused on the network, put the VLAN you want to use into the allowed, and then switched all the NICs inside the VM to tag their traffic.