Configure virtual local area networks for Hyper-V
Virtual local area networks (VLANs) offer one way to isolate network traffic. VLANs are configured in switches and routers that support 802.1q. If you configure multiple VLANs and want communication to occur between them, you'll need to configure the network devices to allow that.
You will need the following to configure VLANs:
- A physical network adapter and driver that supports 802.1q VLAN tagging.
- A physical network switch that supports 802.1q VLAN tagging.
On the host, you'll configure the virtual switch to allow network traffic on the physical switch port. This is for the VLAN IDs that you want to use internally with virtual machines. Next, you configure the virtual machine to specify the VLAN that the virtual machine will use for all network communications.
To allow a virtual switch to use a VLAN
Open Hyper-V Manager.
From the Actions menu, click Virtual Switch Manager.
Under Virtual Switches, select a virtual switch connected to a physical network adapter that supports VLANs.
In the right pane, under VLAN ID, select Enable virtual LAN identification and then type a number for the VLAN ID.
All traffic that goes through the physical network adapter connected to the virtual switch will be tagged with the VLAN ID you set.
To allow a virtual machine to use a VLAN
Open Hyper-V Manager.
In the results pane, under Virtual Machines, select the appropriate virtual machine and then right-click Settings.
Under Hardware, select an virtual switch that's set up with a VLAN.
In the right pane, select Enable virtual LAN identification, and then type the same VLAN ID as the one you specified for the virtual switch.
If the virtual machine needs to use more VLANs, do one of the following:
Connect more virtual network adapters to appropriate virtual switches and assign the VLAN IDs. Make sure to configure the IP addresses correctly and that the traffic you want to route through the VLAN also uses the correct IP address.
Configure the virtual network word adapter in trunk mode using the Set-VMNetworkAdapterVlan cmdlt.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.