Set up Open vSwitch 3.3 for advanced virtual machine networking with VLAN and bridge configuration

Advanced 45 min Apr 11, 2026 257 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Configure Open vSwitch 3.3 to create isolated virtual networks for VMs with VLAN tagging, bridge management, and advanced traffic control. Essential for virtualization environments requiring network segmentation and high-performance VM networking.

Prerequisites

  • Root access
  • Physical network interface for bridge connection
  • Basic understanding of networking concepts
  • Virtual machines or containers to connect

What this solves

Open vSwitch (OVS) provides advanced virtual networking capabilities for virtual machines, containers, and cloud environments. This tutorial configures OVS 3.3 with VLAN tagging, bridge management, and VM network integration for production virtualization environments requiring network isolation and traffic control.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure compatibility with Open vSwitch dependencies.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install Open vSwitch and dependencies

Install Open vSwitch with kernel modules and utilities for bridge and VLAN management.

sudo apt install -y openvswitch-switch openvswitch-common openvswitch-dbg
sudo apt install -y bridge-utils net-tools
sudo dnf install -y openvswitch openvswitch-devel
sudo dnf install -y bridge-utils net-tools

Enable and start Open vSwitch services

Start the OVS database server and switch daemon for bridge and port management.

sudo systemctl enable --now openvswitch-switch
sudo systemctl enable --now ovsdb-server
sudo systemctl enable --now ovs-vswitchd

Initialize Open vSwitch database

Create the initial OVS database configuration if it doesn't exist.

sudo ovs-vsctl --may-exist init

Create virtual bridges and ports

Create primary bridge for VM networking

Create an OVS bridge that will serve as the main virtual switch for VM connections.

sudo ovs-vsctl add-br br0
sudo ovs-vsctl set bridge br0 protocols=OpenFlow10,OpenFlow13
sudo ip link set br0 up

Add physical interface to bridge

Connect a physical network interface to the OVS bridge for external connectivity. Replace eth0 with your actual interface name.

Warning: Adding your management interface to the bridge may cause connection loss. Use a dedicated interface for production deployments.
sudo ovs-vsctl add-port br0 eth1
sudo ip link set eth1 up

Create VLAN-aware bridge

Create a second bridge specifically configured for VLAN traffic segmentation.

sudo ovs-vsctl add-br br-vlan
sudo ovs-vsctl set bridge br-vlan protocols=OpenFlow10,OpenFlow13
sudo ip link set br-vlan up

Configure bridge with IP address

Assign an IP address to the bridge for management access and inter-VLAN routing.

sudo ip addr add 203.0.113.1/24 dev br0
sudo ip route add default via 203.0.113.1 dev br0

Configure VLAN tagging and trunking

Create VLAN access ports

Configure ports with specific VLAN tags for network isolation. These ports will tag all traffic with the specified VLAN ID.

sudo ovs-vsctl add-port br-vlan vlan100 -- set port vlan100 tag=100
sudo ovs-vsctl add-port br-vlan vlan200 -- set port vlan200 tag=200
sudo ovs-vsctl add-port br-vlan vlan300 -- set port vlan300 tag=300

Create VLAN trunk port

Configure a trunk port that carries multiple VLAN tags for connection to external switches or hypervisors.

sudo ovs-vsctl add-port br-vlan trunk0 -- set port trunk0 trunks=100,200,300,400
sudo ovs-vsctl set port trunk0 vlan_mode=trunk

Configure internal VLAN interfaces

Create internal interfaces for each VLAN to enable inter-VLAN routing and management.

sudo ovs-vsctl add-port br-vlan vlan100-int -- set interface vlan100-int type=internal
sudo ovs-vsctl set port vlan100-int tag=100
sudo ip link set vlan100-int up
sudo ip addr add 192.168.100.1/24 dev vlan100-int

sudo ovs-vsctl add-port br-vlan vlan200-int -- set interface vlan200-int type=internal
sudo ovs-vsctl set port vlan200-int tag=200
sudo ip link set vlan200-int up
sudo ip addr add 192.168.200.1/24 dev vlan200-int

Configure VLAN native port

Set up a port with a native (untagged) VLAN for devices that don't support VLAN tagging.

sudo ovs-vsctl add-port br-vlan native100 -- set port native100 tag=100
sudo ovs-vsctl set port native100 vlan_mode=access

Set up VM network integration

Create VM tap interfaces

Create TAP interfaces for virtual machine network connections with proper permissions.

sudo ip tuntap add mode tap tap0 user $(whoami)
sudo ip tuntap add mode tap tap1 user $(whoami)
sudo ip link set tap0 up
sudo ip link set tap1 up

Add VM interfaces to bridges

Connect VM TAP interfaces to appropriate OVS bridges with VLAN configuration.

sudo ovs-vsctl add-port br-vlan tap0 -- set port tap0 tag=100
sudo ovs-vsctl add-port br-vlan tap1 -- set port tap1 tag=200

Configure QoS policies

Apply Quality of Service rules to control bandwidth and prioritize traffic for VM interfaces.

sudo ovs-vsctl -- set port tap0 qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=100000000
sudo ovs-vsctl -- set port tap1 qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=50000000

Configure OpenFlow rules

Add flow rules for advanced traffic control and security policies between VLANs.

sudo ovs-ofctl add-flow br-vlan "priority=100,dl_vlan=100,dl_dst=ff:ff:ff:ff:ff:ff,actions=flood"
sudo ovs-ofctl add-flow br-vlan "priority=50,dl_vlan=100,dl_vlan=200,actions=drop"
sudo ovs-ofctl add-flow br-vlan "priority=10,actions=normal"

Monitor and troubleshoot OVS networks

Configure persistent network settings

Create systemd service to restore OVS configuration after reboots.

[Unit]
Description=Restore Open vSwitch Configuration
After=openvswitch-switch.service
Requires=openvswitch-switch.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/ovs-restore.sh

[Install]
WantedBy=multi-user.target

Create restoration script

Create a script to restore bridge configurations and IP addresses after system restart.

#!/bin/bash

Restore OVS bridge configuration

ip link set br0 up ip link set br-vlan up ip addr add 203.0.113.1/24 dev br0 ip addr add 192.168.100.1/24 dev vlan100-int ip addr add 192.168.200.1/24 dev vlan200-int ip link set vlan100-int up ip link set vlan200-int up
sudo chmod 755 /usr/local/bin/ovs-restore.sh
sudo systemctl enable ovs-restore.service

Enable SNMP monitoring

Configure SNMP agent for OVS monitoring integration with network management systems.

sudo apt install -y snmpd snmp-mibs-downloader
sudo dnf install -y net-snmp net-snmp-utils
sudo ovs-vsctl set-manager ptcp:6640
sudo systemctl restart snmpd

Verify your setup

sudo ovs-vsctl show
sudo ovs-vsctl list bridge
sudo ovs-ofctl dump-flows br-vlan
sudo ovs-vsctl list port
sudo ovs-appctl fdb/show br-vlan
ip addr show br0
ip addr show vlan100-int
sudo systemctl status openvswitch-switch

For comprehensive network monitoring integration, see our guide on automated network topology discovery with SNMP and LLDP to map your virtual infrastructure.

Common issues

SymptomCauseFix
Bridge won't startKernel modules not loadedsudo modprobe openvswitch
No connectivity through bridgeBridge interface downsudo ip link set br0 up
VLAN traffic not workingIncorrect VLAN configurationsudo ovs-vsctl list port | grep vlan to verify tags
VM can't connect to networkTAP interface not in bridgesudo ovs-vsctl list-ports br-vlan to check ports
Inter-VLAN routing failsInternal interfaces misconfiguredsudo ip addr show vlan100-int to verify IPs
QoS policies not appliedIncorrect QoS syntaxsudo ovs-vsctl list qos to verify configuration
OpenFlow rules not workingProtocol version mismatchsudo ovs-ofctl -O OpenFlow13 dump-flows br-vlan
Configuration lost after rebootNo persistence configuredEnable ovs-restore service: sudo systemctl enable ovs-restore

Next steps

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle private cloud infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.