Why do it in the first place?
Software Defined Networking is a new paradigm in the field of systems. More and more areas are slowly including SDN in their system for greater flexibility and control.
But there is a simple problem with SDN as of now.
You see, all great system paradigms became great because of a few simple reasons
- Accessible to the public
- Easy to use
- Cheap in implementation
I believe that SDN has points 1 and 2 covered as it’s an open standard and has nice API. There are also emulators to try them out, like Mininet and Maxinet. However, when it comes to hardware, SDN has a small issue. The cheapest industry-standard SDN-enabled hardware costs a little over a thousand dollars. With hardware costing so much, independent developers can’t do anything. Recently, Northbound Networks tried to solve this problem by introducing Zodiac-FX; a $100 SDN switch with four 100 Mbit port, which is perfect for developing and hacking.
However, I had a different goal.
Why not use an existing popular hardware platform and make a switch out of it?
This is where this guide comes to help. Without further ado, let us dive in
Downloading required stuff
- Login to root and move to home directory of root
- Download openvswitch
- Unpack the archive
tar -xvzf openvswitch-2.5.2.tar.gz
- Install the following
apt-get install python-simplejson python-qt4 libssl-dev python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential pkg-config
apt-get install linux-headers-3.10-3-rpi
Make and install
- In the openvswitch folder, configure, make and install. Installation may take some time, so have patience
./configure --with-linux=/lib/modules/3.10-3-rpi/build make make install
Preparing to initiate OpenVSwitch
- Turn on the openvswitch module. Make sure to turn on the module from inside the directory. In case
modprobedoes not work, restart the Pi
- Create a script
ovs_script.shwith the following code
- Create a file for the database, which will contain the details of the switch
- Make the following directory
mkdir -p /usr/local/etc/openvswitch
- Populate the database, which will be used by the ovswitch
./openvswitch-2.5.2/ovsdb/ovsdb-tool create /usr/local/etc/openvswitch/conf.db /root/openvswitch-2.5.2/vswitchd/vswitch.ovsschema
- Run the script
ovs_script.shin this section
cd openvswitch-2.5.2/datapath/linux modprobe openvswitch
#!/bin/bash ovsdb-server --remote=punix:/usr/local/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 ovs-vsctl show
The switch has now been created
Configuring and Starting the Switch
- Add a new bridge
ovs-vsctl add-br br0
- Connect USB-to-ethernet to the pi. Note their interface names; say it’s
- Connect the interfaces to the bridge
- Turn on the interfaces
- Connect the switch to an external controller. I used a Pox controller.
ovs-vsctl set-controller br0 tcp:10.10.20.20:6633
ovs-vsctl add-port br0 eth1 ovs-vsctl add-port br0 eth2 ovs-vsctl add-port br0 eth3
ifconfig eth1 0 up ifconfig eth2 0 up ifconfig eth3 0 up
The OpenFlow switch is now running.
Turning on the switch the next time
- Turn on the openvswitch module by using
- Run the script/daemon
- Turn on all the OVS interfaces in each switch (