Getting Started OpenFlow OpenvSwitch Tutorial Lab : Setup

I wrote a Python OpenFlow installation app to automate an OpenFlow KVM and Open vSwitch setup found at: OpenFlow, OpenvSwitch and KVM SDN Lab Installation App


Getting Started OpenFlow OpenvSwitch Tutorial Lab - Setup:


Getting Started OpenFlow OpenvSwitch Tutorial Lab : This is an OpenFlow Tutorial using OpenvSwitch and Floodlight controller but any other controller or switch can be used. I have had some requests on some scenarios so I put this together. Adding a few more flexible components. Getting to know all of these packages like KVM, OpenvSwitch are going to be pretty big in the future ecosystem orchestrations.

The video doesn’t have any sound, I am tight on time, sorry. I think it should be pretty straightforward and the video may help if you get stuck. Probably a couple typos here and there I will try and catch over the weekend. We are lacking good lab material on these topics right now so maybe this will save a couple folks some time.


Prerequisites

The KVM requires an x86 machine with either Intel VT or AMD w/AMD-V support. Anything fairly new will have that support in the processor. There are a few older HW builds that support hardware assisted virtualization by enabling it in the bios. Pretty much Googling your machine for hardware virtualization will let you know. Qemu can be run on non VT HW but the machines will probably get brutalized by a few host VMs. When you are setting up the vSwitch either have an out of band or be on it physically. Be careful when you are adding multiple interfaces to bridges since you can spin up a bridging loop pretty quickly unless you have STP on. I recommend a test/dev network or mom’s basement network. If not BPDUguard is your friend :) This is done on a fresh install of 64-bit Ubuntu 12.04 (Precise).

Quick screencast. I highly recommend considering using a small Linux Kernel named linux-0.2.img.bz2 from Qemu if using a laptop or nested hypervisor.



$nano /etc/network/interfaces
Add in your configuration to the file to your physical interface and save the file.
Restart networking. If the configuration is off this will cut you off.
$/etc/init.d/networking restart
$route -n will display your default route if you are having connectivity issues.
$apt-get update
$apt-get dist-upgrade

Install OpenvSwitch


$ apt-get install openvswitch-datapath-source bridge-utils
$ module-assistant auto-install openvswitch-datapath
$ apt-get install openvswitch-common
Verify install
$ovs-vsctl show
ovs_version: “1.4.0+build0″
Processes should look something like this
$ps -ea | grep ovs
26464 ? 00:00:00 ovsdb-server
26465 ? 00:00:00 ovsdb-server
26473 ? 00:00:00 ovs-vswitchd
26474 ? 00:00:00 ovs-vswitchd
26637 ? 00:00:00 ovs-controller
$ /etc/init.d/openvswitch-switch restart

Add your bridge, think of this as a subnet if you aren’t familiar with the term.

Add a physical interface to your virtual bridge for connectivity off box. If you don’t script this part you will probably clip your connection as you zero out eth0 and apply it to br-int. You can pop the commands into a text file and make it executable with chmod +x script.sh

$ ovs-vsctl add-br br-int
$ ovs-vsctl add-port br-int eth0
$ ifconfig eth0 0
#Zero out your eth0 interface and slap it on the bridge interface
#(warning will clip you unless you script it)
$ifconfig br-int 192.168.1.208 netmask 255.255.255.0
#Change your default route
$route add default gw 192.168.1.1 br-int and $route del default gw 192.168.1.1 eth0

Install FloodLight OpenFlow Controller and Attach OpenvSwitch

Install dependencies, apt-get for UB and yum for RH:
apt-get install build-essential default-jdk ant python-dev eclipse git
Clone the Github project and build the jar and start the controller:
$git clone git://github.com/floodlight/floodlight.git
cd into the floodlight directory created.
$cd floodlight
Run ant to build a jar. It will be in the ~/floodlight/target directory.
$ant
Run the controller :
$java -jar target/floodlight.jar
By default it will binds to port 6633 and all ports e.g. 0.0.0.0/0.0.0.0:6633

Attach OpenvSwitch to the Controller

$ovs-vsctl set-controller br-int tcp:192.168.1.208:6633

In the FloodLight console you will see something like this:

[New I/O server worker #1-1] INFO n.f.core.internal.Controller - Switch handshake successful: OFSwitchImpl [/192.168.1.208:49519 DPID[00:00:ba:66:35:e8:38:48]]

 


The output of OVS ‘ovs-vsctl show’ looks something like this:


# ovs-vsctl show
70a40219-8725-46a8-b808-af75c642cac8
Bridge "br-int"
Controller "tcp:192.168.1.208:6633"
is_connected: true
Port "eth0"
Interface "eth0"
Port "br-int"
Interface "br-int"
type: internal
ovs_version: "1.4.0+build0"

Install KVM and Integrate into OVS

$apt-get install kvm uml-utilities
These two scripts bring up the KVM Tap interfaces into your bridge from the CLI. If you copy and paste below make sure the (') does not get formatted improperly. It should be yellow in nano. "switch=br-int" br-int is the name of your bridge in OVS. $nano /etc/ovs-ifup  (open and paste what is below)
#!/bin/sh
switch='br-int'
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1

$nano /etc/ovs-ifdown (open and paste what is below)

#!/bin/sh
switch='br-int'
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1

Make both files executable chmod +x /etc/ovs-ifup /etc/ovs-ifdown


http://www.youtube.com/watch?v=NHHJRDmiqyg

Boot the Guest Virtual Machines


  • Host1
kvm -m 512 -net nic,macaddr=00:00:00:00:cc:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom ubuntu-12.04-desktop-amd64.iso
  • Host2
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-desktop-amd64.iso
  • Host3
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-desktop-amd64.iso
Each one of those will begin loading from the ISO. I just click "Try Ubuntu" when they are booting and just run them from disk since really all we need are nodes that can test connectivity as we push static flows. If it is a more permanent test lab it would make since to install them to disk.

While those are spinning up let’s install curl.

$apt-get install curl

Figure 1. OVS Taps


One they are up assign IP addresses to them by clicking in the top left of the Ubuntu window and type in ’terminal’ no parentheses. Then give them IPs if you want to statically assign them with ifconfig.

sudo ifconfig eth0 192.168.1.x netmask 255.255.255.0

Watch video on YouTube


Check out the rest of the tutorials in this series:


Thanks for stopping by.