Articles

VLAN-aware virtual networking

Tagging inside the host: bridges, virtual switches and the VLAN-aware virtual network.

Reading: 5 minServer & Virtualization

Article cover: VLAN-aware virtual networking

A VLAN is not only a switch-port idea. A VM attached to a host bridge can sit in a VLAN whose tag the host adds and strips: the guest never sees a tag, and the host’s uplink carries many networks over one cable. That is what VLAN-aware means in a hypervisor: the bridge understands the tag and forwards only within the matching network, instead of the host building a bridge and sub-interface per VLAN. The VLAN lives inside the host.

The model: the host applies the tag, the guest never sees it

   one physical uplink, every VLAN together (a trunk on the wire)
   ════════════════════════════════════════════════════════════════════════
        │
   ┌────┴─────────────── VLAN-filtering bridge  br0 ──────────────────────┐
   │  vlan_filtering on: forwards by destination MAC *and* VLAN tag       │
   │                                                                      │
   │  port eno1  (uplink)   tags 10, 20      <- host side sees them tagged │
   │  port vnet0 (VM A)     VLAN 10  pvid    <- untagged on the port       │
   │  port vnet1 (VM B)     VLAN 20  pvid    <- untagged on the port       │
   └──────────────────────────────────────────────────────────────────────┘
        │                          │                         │
   ┌────┴─────┐               ┌────┴─────┐             ┌─────┴────┐
   │  VM A    │               │  VM B    │             │ host IP  │
   │  no tag  │               │  no tag  │             │ on br0   │
   └──────────┘               └──────────┘             └──────────┘

On the wire the frame is tagged; on the guest’s port it is not. The bridge holds one port per guest, assigns each port its guest’s VLAN, and adds the tag only on the uplink.

Two host models: one filtering bridge, or one bridge per VLAN

Linux offers both. A bridge with filtering off ignores the tag — “When disabled, the bridge will not consider the VLAN tag when handling packets” — and the kernel states the default: “VLAN filtering on a bridge is disabled by default”, after which it “will start forwarding frames to appropriate destinations based on their destination MAC address and VLAN tag (both must match)”. The manual exposes this as a bridge-link option, vlan_filtering VLAN_FILTERING, and each port’s VLANs are set with “the bridge vlan option”.

The older model reverses the placement: a sub-interface on the uplink (eno1.5) is bridged by its own device (vmbr0v5) and enslaved as the bridge’s port. Proxmox describes both. In the VLAN-aware model, “each guest’s virtual network card is assigned to a VLAN tag, which is transparently supported by the Linux bridge”. In the traditional model the method “is not transparent and creates a VLAN device with associated bridge for each VLAN. That is, creating a guest on VLAN 5 for example, would create two interfaces eno1.5 and vmbr0v5, which would remain until a reboot occurs.”

The trade is structural: one device with per-port, per-VLAN state, or one bridge per VLAN that multiplies interfaces and turns a VLAN-set change into an interface-count change. Proxmox names the modern form with bridge-vlan-aware yes and bridge-vids 2-4094.

Where the tag is decided: the port, the vNIC, or the guest

Three places a VLAN can be applied, and they are not interchangeable.

  • On the bridge port. The bridge holds a port for the guest’s vNIC and gives it a VLAN (its PVID); untagged frames are placed in it. The kernel’s default PVID is VLAN 1 — “VLAN ID applied to untagged and priority-tagged incoming packets” — and setting it to zero makes ports “not accept VLAN-untagged traffic”.
  • On the vNIC. The hypervisor tags the guest’s traffic as it leaves, transparently: libvirt’s <vlan> element “can specify one or more VLAN tags to apply to the guest’s network traffic” when the connection supports tagging transparent to the guest. One tag can be a trunk (trunk='yes'), several can be listed together — “multiple subelements can be specified” — and a native VLAN can be marked with nativeMode. It works on Open vSwitch, standard Linux bridges, SR-IOV and macvtap passthrough; libvirt’s own NAT and routed networks do not.
  • In the guest. The guest is handed a trunk and tags its own frames. Proxmox calls this “the setup is completely done inside the guest and can not be influenced from the outside”, and “you can use more than one VLAN on a single virtual NIC.” It is trunk mode: “Trunk mode is also possible, but that makes configuration in the guest necessary.”

The vocabulary differs. Proxmox exposes tag= — “VLAN tag to apply to packets on this interface” — and trunks= — “VLAN trunks to pass through this interface”. Hyper-V puts the choice on the switch port: “Trunk mode to a VM : Enables administrators to set up a specific VM as a virtual appliance, and then direct traffic from various VLANs to that VM”, and an isolated “VLAN : Enables administrators to segregate traffic on multiple vlans, to more easily establish isolated tenant communities.” A Hyper-V switch can also stand aside: a forwarding extension can turn on the transparency that tells “the Hyper-V Virtual Switch to pass and take no action on VLAN tags.”

Where the tag is decided What the guest sees Host example
On the bridge port (PVID) nothing Linux VLAN-aware bridge (vlan_filtering 1)
On the vNIC (host applies it) nothing libvirt <vlan><tag id='42'/></vlan>; Proxmox tag=42
In the guest (trunk handed over) the tag Proxmox trunks=; Hyper-V trunk mode to a VM

The traps: the VLAN that never reaches the wire

The failures are one: a VLAN present where it is not needed, absent where it is.

  • On the host but not the uplink. A guest can be cleanly in VLAN 30 on the bridge while the physical port the host uplinks through is an access port in another VLAN, or a trunk that does not carry VLAN 30. It leaves the host tagged and is dropped or flattened on the wire; the bridge cannot repair a switch that does not know the VLAN.
  • The trunk is one failure domain. Every VLAN riding one uplink shares one cable, one port and one upstream link; a loop, a spanning-tree event or a failed link takes down all of them at once. VLAN-awareness does not change this: it is the same physical trunk the access/trunk sheet describes, terminated one layer inward.
  • The tag has a wrong end. The host trunk’s native VLAN must match the native VLAN upstream, or two VLANs merge. Which VLAN is native is a property of both ends; the host cannot enforce it alone.
  • A VLAN is not a firewall. The bridge forwards by destination MAC and VLAN tag — “both must match” — but that is a membership test, not a policy: a guest in trunk mode can tag its own frames into a VLAN it was never granted. Vendor prose calling VLANs “secure network segments that prevent unauthorized lateral movement between workloads” describes a segmentation aid, not an access control. Port ACLs and firewalls above the bridge are what enforce policy; prove the boundary with something that can deny.

Level and prerequisites

L4 — infrastructure design, not a single mechanism: this sheet decides where a VLAN is enforced in a virtualised host and what that costs in configuration, failure scope and trust, rather than teaching the tag. It presupposes the L3 sheet beneath it (the vNIC, host bridge and switch port) and, under that, hosts, VMs and virtual devices. The 802.1Q tag, access and trunk ports and the native VLAN belong to the Networking area, named here and not developed. It leads into the sheets where a whole device is handed over rather than a tagged port: a passed-through NIC bypasses the host bridge and its VLAN logic.

Where to go next

The wire-level mechanics — the tag, access/trunk and the native VLAN — are the Networking sheets, named as the boundary; bonding and link aggregation carry the trunk instead of one uplink. Handing a guest a real NIC instead of a tagged port removes the host from the path, which is the SR-IOV and PCIe passthrough sheets.

References

Nodrius Field Kit — cover

Get the Nodrius Field Kit

Enter your email and we'll send you the complete Field Kit: eight technical resources in one download.

Your email address is sent to Nodrius and used to deliver the Field Kit to you by email. Marketing messages are separate and optional: the checkbox does not affect your download, and you are only added to our updates list if you tick it. Privacy Policy.

Privacy & cookies

This site does not use cookies, analytics or tracking, and it does not profile you. There is nothing technical to switch off, so Accept and Reject change nothing about how the site works: either choice lets you browse everything normally.

The only difference is what your browser remembers: two entries in local storage — your choice here, so this notice is not shown again, and a marker that the Field Kit offer has already been made — so the offer is presented once and not on every page. They contain no identifier, they are not shared with anyone, and the site sets no cookie for either.

What we do with your data
How your email address is used when you ask for a Resource, how long it is kept and which rights you have — in the Privacy Policy.
What the site stores in your browser
Two entries in local storage — your choice on this notice and whether the Field Kit offer has been shown — and no cookies, no session storage, no third-party content: in the Cookie Policy.