Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

VLAN filter support on bridge

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

    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

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.