大网数据广告活动
Hyper-V与虚拟化

Configure virtual local area networks for Hyper-V

· 52CE 我爱测

Learn how to configure a virtual local area network (VLAN) for use by virtual machines on a Hyper-V host.

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 need to configure the network devices to allow that.

To set up VLANs, make sure you have:

  • 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, set up the virtual switch to let network traffic on the physical switch port for the VLAN IDs you use with virtual machines. Then, set up the virtual machine to specify the VLAN it uses for all network communications.

Allow a virtual switch to use a VLAN

  1. In Hyper-V Manager, select Virtual Switch Manager from the Actions pane on the right.

  2. In Virtual Switch Manager, under Virtual Switches on the left, select a virtual switch connected to a physical network adapter that supports VLANs.

  3. Under VLAN ID in the right pane, select Enable virtual LAN identification for management operating system and then type a number for the VLAN ID.

  4. Select OK.

All traffic that goes through the physical network adapter connected to the virtual switch is tagged with the VLAN ID you set on the virtual switch and virtual machines.

Allow a virtual machine to use a VLAN

  1. In Hyper-V Manager, under Virtual Machines, right-click the appropriate virtual machine and select Settings. Or, select the machine and then select Settings under the machine name in the right pane.

  2. On the Settings screen, under Hardware in the left pane, select a Network Adapter that has a virtual switch that's set up with a VLAN.

  3. Under VLAN ID 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.

  4. Select OK.

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 adapter in trunk mode by using the Set-VMNetworkAdapterVlan cmdlet.

Related content

Hyper-V virtual switch

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 08/18/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。