Openvswitch on fedora with kvm.

Openvswitch is the software used on both physical and virtual environments to implement L2 switching.

Instalallation of openvswitch.
#dnf install -y virt-install libvirt openvswitch

Enabling the openvswitch service and daemon.

#systemctl enable openvswitch 
Created symlink /etc/systemd/system/multi-user.target.wants/openvswitch.service → /usr/lib/systemd/system/openvswitch.service.

#systemctl start  openvswitch 

#systemctl status   openvswitch 
● openvswitch.service - Open vSwitch
   Loaded: loaded (/usr/lib/systemd/system/openvswitch.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2018-04-07 18:44:06 IST; 3s ago
  Process: 31455 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 31455 (code=exited, status=0/SUCCESS)
      CPU: 3ms

Apr 07 18:44:06 server.sand.box systemd[1]: Starting Open vSwitch...
Apr 07 18:44:06 server.sand.box systemd[1]: Started Open vSwitch.

Adding a network interfcace to ovs bridge ovsbr0

#ovs-vsctl add-br ovsbr0

#ovs-vsctl add-port ovsbr0 enp9s0 

#ifconfig ovsbr0 192.168.15.15/20

#dhclient ovsbr0

#ovs-vsctl  show 
2826ab86-417c-4b89-8860-12f0e641e5b6
    Bridge "ovsbr0"
        Port "enp9s0"
            Interface "enp9s0"
        Port "ovsbr0"
            Interface "ovsbr0"
                type: internal
    ovs_version: "2.7.3"

Modify the enp9s0 network configuration file

#TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp9s0
UUID=aa435e1d-03bc-3c06-8d2b-c03836c03b80
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
DEVICE=enp9s0
DEVICETYPE="ovs"
TYPE="OVSPort"
OVS_BRIDGE="ovsbr0"
#IPADDR=192.168.15.15
PREFIX=20
GATEWAY=192.168.0.4
IPV6_PRIVACY=no
DNS1=4.2.2.2
DNS2=8.8.8.8
DOMAIN="sand.box server.sand.box"
ZONE=public

Creating a bridge configuration file to keep changes persistent across reboots.

DEVICE="ovsbr0"
DEVICETYPE="ovs"
TYPE="OVSBridge"
ONBOOT="yes"

MACADDR="00:1c:23:01:fb:dc"
OVS_EXTRA="set bridge $DEVICE other-config:hwaddr=$MACADDR"

OVSBOOTPROTO="dhcp"
OVSDHCPINTERFACES="enp9s0"

Add network interface to the kvm guest

   
      
      
      
      
      

After kvm guest is booted up we can see that ip is the same range as the bridge br0.