2. contents
1. Overview about OVS
2. Install OVS in local pc
3. How to use OVS with KVM
3. 1 Overview about OVS(1/2)
Open vSwitch is a virtual switch for hypervisors
providing network connectivity to virtual machines.
Architecture OVS:
4. 1. Overview about OVS(2/2)
Ovsdb-server: is a management protocol used to
manipulate the configuration of Open vSwitches
Ovs-vswitchd: is a daemon that implements the
switch, along with a companion Linux kernel module
for flow-based switching
Openvswitch.ko: is kernel module.
5. 2. Install OVS on local PC(1/5)
Download ovs package from:
http://openvswitch.org/releases/openvswitch-
2.0.0.tar.gz
Userland installation: follow as INSTALL.Debian
guide or follow as step by step:
Step 1: download source and extract.
$ wget http://openvswitch.org/releases/openvswitch-
2.0.0.tar.gz
$ tar zxf openvswitch-2.0.0.tar.gz
$ rm openvswitch-2.0.0.tar.gz
$ cd openvswitch-2.0.0
6. 2. Install OVS on local PC(2/5)
Step 2: configure for to build.
$ mkdir build
$ cd build
$ mkdir –p /usr/local/ovs
$ ./configure –prefix=/usr/local/ovs --with-
linux=/lib/modules/`uname -r`/build
Step 3: build and check build
$ make
$ make check
Step 4: install
$ make install
7. 2. Install OVS on local PC(3/5)
Install kernel modules:
$ make modules_install
If you get error as:
Then follow as:
make[2]: Entering directory `/usr/src/linux-headers-3.8.0-33-
generic'
INSTALL /root/openvswitch-2.0.0/datapath/linux/openvswitch.ko
Can't read private key
DEPMOD 3.8.0-33-generic
make[2]: Leaving directory `/usr/src/linux-headers-3.8.0-33-generic'
depmod `sed -n 's/#define UTS_RELEASE "([^"]*)"/1/p'
/lib/modules/3.8.0-33-generic/build/include/generated/utsrelease.h`
9. 2 Install OVS on local PC(5/5)
Before starting ovs-vswitchd: unload bridge module
with command $ rmmod bridge
Initialize database
Start open vswitch daemon:
$ ovsdb-server /usr/local/ovs/etc/openvswitch/conf.db
--remote=punix:/usr/local/ovs/var/run/openvswitch/db.sock
--remote=db:Open_vSwitch,Open_vSwitch,manager_options
--private-key=db:Open_vSwitch,SSL,private_key
--certificate=db:Open_vSwitch,SSL,certificate
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert
--pidfile –detach
$ ovs-vsctl --no-wait init
$ ovs-vswitchd --pidfile --detach
10. 3 How to use OVS with KVM(1/6)
We will to use kvm to emulator a system network:
Install kvm:
$ apt-get install kvm uml-utilities virt-manager qemu-kvm
Model system for this case study:
11. 3 How to use OVS with KVM(2/6)
Create bridge br0 and add eth0 to br0 with script:
#!/bin/sh
enable_bridge(){
ovs-vsctl add-br br0
ovs-vsctl add-port br0 eth0
ifconfig eth0 0
ifconfig br0 192.168.1.25 netmask 255.255.255.0
route add default gw 192.168.1.1 br0
}
disable_bridge(){
ovs-vsctl del-port br0 eth0
#restore config eth0
reboot
}
case $1 in
up)
enable_bridge
;;
down)
disable_bridge
;;
*)
echo "USAGE: {up|down}"
;;
esac
12. 3 How to use OVS witch KVM(3/6)
Create bridge br0 and add eth0 to br0 with script:
Create 2 scripts bring up the kvm tap interface into br0.
$ vi /etc/ovs-ifup
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1
$ chmod a+x /etc/ovs-ifup
$ vi /etc/ovs-ifdown
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1
$ chmod a+x /etc/ovs-ifdown
- Save script as ovs_network
$ chmod a+x ovs_network
$ ./ovs_network up
13. 3. How to use OVS with KVM(4/6)
Start VM1, VM2
$ kvm -m 512 -net nic,macaddr=00:11:22:CC:CC:10 -net tap,script=/etc/ovs-
ifup,downscript=/etc/ovs-ifdown -cdrom ubuntu-12.04.3-desktop-i386.iso
$ kvm -m 512 -net nic,macaddr=22:22:22:00:CC:10 -net tap,script=/etc/ovs-
ifup,downscript=/etc/ovs-ifdown -cdrom ubuntu-12.04.3-desktop-i386.iso
If you get this kvm: -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-
ifdown: Device ‘tap’ could not be initialized
Just delete the tap0. Need to dig into a work around cleaner than
scripts.
$ ovs-vsctl del-port tap0
15. 3 How to use OVS with KVM(6/6)
Show configuration of system with ovs-vsctl
command:
Reference:
http://networkstatic.net/installing-open-vswitch-with-
kvm/
http://networkstatic.net/getting-started-ovsdb/