Openvswith with kvm bridge network.

By | April 17, 2018

Openvswith is a virtual switch  production level software, that can be used in virtual switch in VM environments like kvm , virtualbox etc..

In case of vm’s network connection to outer world is established by NAT or Bridge (Layer2 device) , this model is good for single server vm guests , openvswitch is suited for multiserver vm guests connection.

Installing openvswitch on fedora.

$dnf install openvswitch -y

$systemctl enable openvswitch.service

$systemctl start openvswitch.service

$systemctl status openvswitch.service

Checking the openvswitch service.

sudo systemctl status openvswitch.service
● openvswitch.service - Open vSwitch
   Loaded: loaded (/usr/lib/systemd/system/openvswitch.service; enabled; vendor preset: disabled)
   Active: active (exited) since Wed 2018-04-18 01:12:58 IST; 58min ago
 Main PID: 1223 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/openvswitch.service

Apr 18 01:12:58 systemd[1]: Starting Open vSwitch...
Apr 18 01:12:58 systemd[1]: Started Open vSwitch.

Add an ovsbridge and add a bridge to it.

#ovs-vsctl add-br ovsbr0

#ovs-vsctl show

    Bridge "ovsbr0"
        Port "ovsbr0"
            Interface "ovsbr0"
                type: internal
    ovs_version: "2.7.3"

Adding a virtual interface to ovsbridge.

$ip link add name veth0 type veth peer name veth1

Associating virtual interface veth0 to bridge br0
$brctl addif br0 veth0

$brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.001c2301fbdc	no		enp9s0
docker0		8000.0242ac504bd3	no		
virbr0		8000.525400d95bb9	yes		virbr0-nic
virbr2		8000.5254007b2673	yes		virbr2-nic

Adding virtual interface veth1 to ovsbridge

$sudo ovs-vsctl add-port ovsbr0 veth1

$sudo ovs-vsctl show
    Bridge "ovsbr0"
        Port "veth1"
            Interface "veth1"
        Port "ovsbr0"
            Interface "ovsbr0"
                type: internal
    ovs_version: "2.7.3"

edit the xml config file of kvm guest and add below line.