Linux VPS

Use Open vSwitch with KVM: bridges, VLANs and libvirt

Install Open vSwitch on a KVM host, create an OVS bridge, attach VMs through libvirt, tag VLANs per VM, inspect flows and ports, and decide when OVS beats a plain Linux bridge.

AdvancedKVM hosts2 min read

Open vSwitch (OVS) is a programmable virtual switch used by OpenStack, OVN and many large virtualization platforms. On a single KVM host it gives you per-port VLAN tagging, mirroring, QoS and flow-level control beyond a plain Linux bridge. This guide shows how to use Open vSwitch with KVM.

Before you start

Install Open vSwitch

sudo apt install -y openvswitch-switch

RHEL family: install openvswitch from the appropriate repository (for example the NFV or OpenStack SIG repos) and enable openvswitch.

Create an OVS bridge

sudo ovs-vsctl add-br ovsbr0
sudo ovs-vsctl add-port ovsbr0 eno1

Then move the host IP from eno1 to ovsbr0. With Netplan you can declare it persistently:

network:
  version: 2
  ethernets:
    eno1: {}
  bridges:
    ovsbr0:
      interfaces: [eno1]
      openvswitch: {}
      addresses: [203.0.113.10/24]
      routes:
        - to: default
          via: 203.0.113.1

Apply from the console with sudo netplan try.

Connect libvirt VMs

In the VM XML (virsh edit vmname):

<interface type='bridge'>
  <source bridge='ovsbr0'/>
  <virtualport type='openvswitch'/>
  <model type='virtio'/>
</interface>

With virt-install: --network bridge=ovsbr0,virtualport_type=openvswitch,model=virtio.

Tag VLANs per VM

Add a VLAN tag in the interface definition:

<vlan><tag id='100'/></vlan>

The uplink switch port must be a trunk carrying VLAN 100. You can also define a libvirt network with portgroups for each VLAN so VMs simply pick a portgroup.

Inspect and debug

TaskCommand
Show bridges and portsovs-vsctl show
Port statisticsovs-ofctl dump-ports ovsbr0
Flow tableovs-ofctl dump-flows ovsbr0
Learned MACsovs-appctl fdb/show ovsbr0

OVS vs Linux bridge

  • Linux bridge: simpler, built in, enough for most single-host setups (VLAN-aware bridges cover basic tagging).
  • OVS: use for SDN, OVN, overlays (VXLAN/Geneve), port mirroring, fine-grained QoS and OpenFlow rules.

Troubleshooting

  • Host lost network: the IP is still on eno1 or the bridge has no IP; fix from console.
  • VM gets no traffic on VLAN: tag missing or the switch port is not a trunk.
  • libvirt error about virtualport: OVS service not running; systemctl status openvswitch-switch.

Frequently asked questions

Does OVS slow down traffic?

Its kernel datapath performs well; DPDK-accelerated OVS exists for very high packet rates.

Do VPS panels use OVS?

Some do, many use Linux bridges. It depends on the panel and configuration.

Can I mix OVS and Linux bridges?

Yes, on different interfaces, but keep the design simple.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.