Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

VLAN filter support on bridge

September 14, 2017
Hangbin Liu
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

Share:

    This blog aims for Administrators who need to handle large numbers of VLANs in virtualization/namespaces with a bridge. With the VLAN filter, people don't need to create dozens of VLANs and bridges anymore. With only ONE bridge, you can control all VLANs. See more details in this blog.

    Bridge and VLAN

    Virtualization, Cloud, OpenStack, and Docker. These technologies are getting increasingly important and popular. But behind them, there are two indispensable features: Bridge and VLAN.

    A bridge is a way to connect two Ethernet segments together in a protocol independent way. Packets are forwarded based on Ethernet address, rather than IP address (as a router would do). Since forwarding is done at Layer 2, all protocols can go transparently through the bridge. The Linux bridge is actually a virtual switch and widely used with KVM/QEMU hypervisor, namespaces, etc.

    VLAN is another very important function in virtualization. It allows network administrators to group hosts together even if the hosts are not on the same physical network switch. This can greatly simplify network design and deployment. Also, it can separate hosts/guests under the same switch/bridge into different subnets.

    These two important features used to be considered as two completely distinct features and we needed to configure complex topologies to combine them together. In this blog, we will show the new bridge feature, VLAN filter, which hopefully makes life easier.

    This feature was introduced in Linux kernel 3.8 and was added to RHEL in version 7.0.

    Let's take an example that is widely used in virtualization: different subnets on a bridge with bond load balance.

    Without VLAN filtering

    Previously, if we wanted to use distinct subnets with guests on a virtualization server, we need to create multiple VLANs and bridges. Something like:

    VLAN filter support on bridge

    And the steps would be, approximately:

    1. Create a bond device.
      # ip link add bond0 type bond
      # ip link set bond0 type bond miimon 100 mode balance-alb
      # ip link set eth0 down
      # ip link set eth0 master bond0
      # ip link set eth1 down
      # ip link set eth1 master bond0
      # ip link set bond0 up
    2. Create VLANs on bond. We need to create more VLANs if dictated by requirements.
      # ip link add link bond0 name bond0.2 type vlan id 2
      # ip link set bond0.2 up
      
      # ip link add link bond0 name bond0.3 type vlan id 3
      # ip link set bond0.3 up
    3. Add a bridge device, to which we can attach the VLAN interface.
      # ip link add br0 type bridge
      # ip link set bond0.2 master br0
      # ip link set br0 up
      
      # ip link add br1 type bridge
      # ip link set bond0.3 master br1
      # ip link set br1 up
    4. Attach tap device to bridge.
      # ip link set guest_1_tap_0 master br0
      # ip link set guest_2_tap_0 master br0
      
      # ip link set guest_2_tap_1 master br1
      # ip link set guest_3_tap_0 master br1

    When creating a bond, VLAN, and bridge interfaces, we can use nmcli or update ifcfg files to make the configuration permanent.

    With VLAN filtering

    Now, with the VLAN filtering feature, we only need one bridge interface and no VLAN interfaces.

    Let's see how to do that.

    image

    1. Create a bond device, the same as above.
      # ip link add bond0 type bond
      # ip link set bond0 type bond miimon 100 mode balance-alb
      # ip link set eth0 down
      # ip link set eth0 master bond0
      # ip link set eth1 down
      # ip link set eth1 master bond0
      # ip link set bond0 up
    2. Create the bridge interface, enable VLAN filter and attach the bond interface to the bridge directly.
      # ip link add br0 type bridge
      # ip link set br0 up
      # ip link set br0 type bridge vlan_filtering 1
      
      # ip link set bond0 master br0
    3. Attach the tap device to the bridge.
      # ip link set guest_1_tap_0 master br0
      # ip link set guest_2_tap_0 master br0
      
      # ip link set guest_2_tap_1 master br0
      # ip link set guest_3_tap_0 master br0
    4. Set the tap interface with the VLAN filter.
      # bridge vlan add dev guest_1_tap_0 vid 2 pvid untagged master
      # bridge vlan add dev guest_2_tap_0 vid 2 pvid untagged master
      
      # bridge vlan add dev guest_2_tap_1 vid 3 pvid untagged master
      # bridge vlan add dev guest_3_tap_0 vid 3 pvid untagged master
      
      # bridge vlan add dev bond0 vid 2 master
      # bridge vlan add dev bond0 vid 3 master
    5. To dump the VLAN information from the bridge interface.
      # bridge vlan show
      port    vlan ids
      bond0    1 PVID Egress Untagged
               2
               3
      
      br0      1 PVID Egress Untagged
      
      guest_1_tap_0    1 Egress Untagged
               2 PVID Egress Untagged
      
      guest_2_tap_0    1 Egress Untagged
               2 PVID Egress Untagged
      
      guest_2_tap_1    1 Egress Untagged
               3 PVID Egress Untagged
      
      guest_3_tap_0    1 Egress Untagged
               3 PVID Egress Untagged
      

    Summary

    With the VLAN filter, the Linux bridge acts more like a real switch now. We don't need to create multiple VLANs and bridges anymore. The topology appears simpler and easier to manage. Administrators can set up distinct subnets on virtualization servers more easily and efficiently.

    Note: The performance of these two scenarios is almost the same when guests communicate between Hosts/Servers. But there will be a little decrease when VMs communicate to each other on the same Host/Server. That's because with the previous method the same VLAN is on the same bridge. But with the VLAN filter, all VLAN are in one bridge. So we need to tag/untag VLANs when communicate.


    Download this Kubernetes cheat sheet for automating deployment, scaling and operations of application containers across clusters of hosts, providing container-centric infrastructure.

    Last updated: August 11, 2023

    Recent Posts

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue