Skip to content
Tags

,

SDN and OVS lab

by on January 9, 2013

following this http://networkstatic.net/openflow-openvswitch-and-kvm-sdn-lab-installation-app/ to install SDN lab I got some issues.

Update: I got the same error as in here: https://groups.google.com/a/openflowhub.org/forum/?fromgroups=#!topic/floodlight-dev/1xXekKhXRrM

so need to do this:

  • service openvswitch-controller stop
  • ovs-vsctl set-controller br0 tcp:<your IP here>

As i’m a script person, I modified the python into bash script:

#!/bin/bash
#
# sdn_lab_install_v1.2_opt2.sh
#
# based on http://networkstatic.net/openflow-openvswitch-and-kvm-sdn-lab-installation-app/
# Option 2
#
sdnlog=/tmp/sdn_install_`date +%Y%m%d_%H%M%S`.log
touch $sdnlog
#
#define IP , GW and Netmask
#
export strGW=`route -n | grep 'UG[ \t]' | awk '{print $2}'`
export strIP=`ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'`
export strNetMask=`ifconfig eth0 | sed -rn '2s/ .*:(.*)$/\1/p'`
export PROXYIP="TODO: Put your proxy here"

echo strGW=$strGW >> $sdnlog
echo strIP=$strIP >> $sdnlog
echo strNetMask=$strNetMask >> $sdnlog

#
#install all required packages
#
function aptget () {
echo function aptget >> $sdnlog
apt-get update
apt-get install -y xterm
apt-get install -y git
apt-get install -y kvm
apt-get install -y qemu-kvm
apt-get install -y python-simplejson
apt-get install -y python-qt4
apt-get install -y python-twisted-conch
apt-get install -y automake
apt-get install -y autoconf
apt-get install -y gcc
apt-get install -y uml-utilities
apt-get install -y libtool
apt-get install -y build-essential
apt-get install -y pkg-config
apt-get install -y linux-headers-`uname -r`
apt-get install -y openvswitch-controller
apt-get install -y default-jre
apt-get install -y python-dev
apt-get install -y curl
}

#
# config proxy
#
function configProxy () {
echo config proxy >> $sdnlog
git config --global http.proxy http://${PROXYIP}:8080
export http_proxy=http://${PROXYIP}:8080
}
#
# Install OVS
# 
function installOVS() {
echo Install OVS >> $sdnlog
###git clone http://openvswitch.org/openvswitch # Somehow not available!!
###cd openvswitch
wget http://openvswitch.org/releases/openvswitch-1.7.1.tar.gz
tar zxf openvswitch-1.7.1.tar.gz
cd openvswitch-1.7.1
./boot.sh
./configure --with-linux=/lib/modules/`uname -r`/build
make && make install
insmod datapath/linux/openvswitch.ko
insmod datapath/linux/brcompat.ko
mkdir -p /usr/local/etc/openvswitch
cd ..
}
function runOVS () {
echo function runOVS >> $sdnlog
echo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema >> $sdnlog
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
echo ovsdb-server /usr/local/etc/openvswitch/conf.db >> $sdnlog
ovsdb-server /usr/local/etc/openvswitch/conf.db \
 --remote=punix:/usr/local/var/run/openvswitch/db.sock \
 --remote=db:Open_vSwitch,manager_options \
 --private-key=db:SSL,private_key \
 --certificate=db:SSL,certificate \
 --bootstrap-ca-cert=db:SSL,ca_cert \
 --pidfile \
 --detach \
 --log-file
echo ovs-vsctl --no-wait init >> $sdnlog
ovs-vsctl --no-wait init
echo ovs-vswitchd --pidfile --detach >> $sdnlog
ovs-vswitchd --pidfile --detach
}
#
# Get small linux image
# 
function getsmallLinux() {
echo Get small linux image >> $sdnlog
wget http://wiki.qemu.org/download/linux-0.2.img.bz2
bunzip2 linux-0.2.img.bz2
}
#
# Define ifup and ifdown
#
function defif () {
echo Define ifup and ifdown >> $sdnlog
echo "#!/bin/sh
switch='br-int'
/sbin/ifconfig \$1 0.0.0.0 up promisc
ovs-vsctl add-port \${switch} \$1
" > /etc/ovs-ifup
chmod 755 /etc/ovs-ifup
echo "#!/bin/sh
switch='br-int'
/sbin/ifconfig \$1 0.0.0.0 down
ovs-vsctl del-port \${switch} \$1
" > /etc/ovs-ifdown
chmod 755 /etc/ovs-ifdown
}
#
# Define bridge
#
function defineBrige () {
echo Define bridge >> $sdnlog
ovs-vsctl add-br br-int
ovs-vsctl add-port br-int eth0
ovs-vsctl set-controller br-int tcp:${strIP}:6633
}

#
# Define IP
#
function defineIP () {
echo Define IP>> $sdnlog
ifconfig br-int ${strIP} netmask ${strNetMask}
route add default gw ${strGW} br-int
ifconfig eth0 0
}
#
# FloodLight
#
function FloodLight () {
echo FloodLight >> $sdnlog
fllog=/var/log/floodloght_`date +%Y%m%d_%H%M%S`.log
wget http://floodlight.openflowhub.org/files/floodlight.jar
nohup java -jar floodlight.jar > $fllog 2>&1 &
}
#
# Done FloodLight
#
function doneFloodLight () {
echo Done FloodLight >> $sdnlog
echo "
############################################################################
# Installation complete! Now start a VM or run the bash script in the post.#
############################################################################
# Copy and paste all three lines into the console from the SAME directory #
# you installed the script from that has the downloaded "linux-0.2.img" #
# image. Do this with in the Ubuntu GUI. Then in the window give it an #
# address on your subnet and a default gateway in the VM that boots in the #
# QEMU window that pops up. Break out of the QEMU window inside VirtualBox #
# use alt + control + command a few times to free the mouse pointer. #
# Example IP--> **ifconfig eth0 192.168.1.20 netmask 255.255.255.0** #
# Example Default Gateway-->**route add default gateway 192.168.1.1** #
# To start a VM copy and paste this into the console #
############################################################################
#Use unique Mac addresses for hosts e.g. cc:10, cc:11 see details in post #
############################################################################
Examples to copy and paste (Notice unique MAC addresses on each VM 01, 02, 03)
kvm -m 128 -net nic,macaddr=22:22:22:00:cc:01 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -hda linux-0.2.img &
kvm -m 128 -net nic,macaddr=22:22:22:00:cc:02 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -hda linux-0.2.img &
kvm -m 128 -net nic,macaddr=22:22:22:00:cc:03 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -hda linux-0.2.img &
Booting one VM with a MAC address of AA:AA:12:34:56:78 as an example.
When it boots you give it an IP address and gatewat as explanined above.
Type 'ovs-vsctl show' to the the VNIC (tap0) and OVS configuration
############################################################################
# FloodLight Controller running at http://{strIP}:8080/ui/index.html #
# Put the URL above in a web browser to see the web UI #
################################################################################
# -More information about what you can do with this Lab at: #
# http://networkstatic.net/openflow-openvswitch-and-kvm-sdn-lab-installation-app/ #
# Comments at Twitters @networkstatic, Thanks- Brent Salisbury #
################################################################################
"
}
#
# boot KVM
#
function bootKVM () {
echo boot KVM >> $sdnlog
echo kvm -m 128 -net nic,macaddr=33:22:22:00:cc:01 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -hda linux-0.2.img & >> $sdnlog
kvm -m 128 -net nic,macaddr=33:22:22:00:cc:01 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -hda linux-0.2.img &
}

#
# MAIN
#
aptget
configProxy 
installOVS
runOVS 
getsmallLinux
defif
defineBrige 
defineIP 
FloodLight 
doneFloodLight
bootKVM
Advertisements

From → Uncategorized

One Comment

Trackbacks & Pingbacks

  1. WTF Comments | a Linux Rat in the Lab

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: