Tuesday, January 14, 2014

[Thoughts] RESTful control of switches

OpenFlow is already the standard Southbound API in SDN field, but OpenFlow is the one of the many SouthBound approaches. In SDN solution, we don't necessarily need to use OpenFlow protocol to control data plane. RESTful API is another way to control or configure switches ( data plane ) if they supports. Arista Networks has provides Arista eAPI as RESTful control of switches. For more information in details, please refer to this article: http://blog.sflow.com/2013/08/restful-control-of-switches.html

[LXC] How to use LXC?

At the first glimpse, I was amazed by its way to provide a lightweight container in virtual environment. With shell scripts combining, we can use these to build a convenient and powerful automation solution to test all kind of programs that need multiple virtual machines within a server host ( at least my focus is on the automation test...XD ). There are already a bunch of articles to introduce LXC. Here I only list some common use commands for reference quickly:

# Install LXC
sudo apt-get install lxc

# Create a Linux Container named base ( -t: template, -n: namespace )
sudo lxc-create -t ubuntu -n base

# Start the Linux Container ( -d: daemon )
sudo lxc-start -n base -d

# Stop the Linux Container
sudo lxc-stop -n base

# List Linux Containers
lxc-ls --fancy

# Clone the Linux Container
lxc-clone -o base -n newvm1

# Access the container
lxc-console -n newvm1

# Shudown
lxc-shutdown -n test-container

# Destroy
lxc-destroy -n test-container


LXC can be controlled via Libvirt:
http://blog.scottlowe.org/2013/11/27/linux-containers-via-lxc-and-libvirt/

Exploring LXC Networking:

Autostart
By default, containers will not be started after a reboot, even if they were running prior to the shutdown.
To make a container autostart, you simply need to symlink its config file into the /etc/lxc/auto directory:
ln -s /var/lib/lxc/test-container/config /etc/lxc/auto/test-container.conf

Reference:
https://www.digitalocean.com/community/articles/getting-started-with-lxc-on-an-ubuntu-13-04-vps
http://www.janoszen.com/2013/05/14/lxc-tutorial/

Tuesday, January 7, 2014

[Open vSwitch] The basic introduction of Open vSwitch

I post a slide to give a basic introduction of Open vSwitch. For the more in details, please check out the SlideShare URL as follows:
http://www.slideshare.net/teyenliu/the-basic-introduction-of-open-vswitch


Some Useful example of the OVS commands:
sudo ovs-vsctl show
sudo ovs-vsctl add-br mybridge
sudo ovs-vsctl del-br mybridge
sudo ovs-vsctl add-port mybridge port-name
sudo ovs-vsctl del-port mybridge port-name
sudo ovs-vsctl list Bridge/Port/Interface/...
sudo ovs-appctl fdb/show mybridge
sudo ovs-ofctl show mybridge
sudo ovs-ofctl dump-flows mybridge
sudo ovs-ofctl add-flow mybridge dl_src=02:a2:a2:a2:a2:a2,dl_dst=02:b2:b2:b2:b2:b2,in_port=2,dl_type=0x0800,nw_src=10.0.0.1,nw_dst=10.0.0.2,actions=output:6
sudo ovs-ofctl del-flows mybridge dl_src=02:a2:a2:a2:a2:a2,dl_dst=02:b2:b2:b2:b2:b2,in_port=2,dl_type=0x0800,nw_src=10.0.0.1,nw_dst=10.0.0.2
sudo ovs-ofctl add-flow dp0 in_port=2,actions=output:6
# This will delete all the flow entries in the flow table
sudo ovs-ofctl del-flows mybridge

Friday, January 3, 2014

[GNS3] All the related URLs with GNS3 and Open vSwitch

To play with Openvswitch in GNS3, here is Openvswitch 1.2.2 installed on Microcore 4.0 Linux as Qemu image.
http://brezular.com/2013/09/17/linux-core-qemu-and-virtualbox-appliances-download/

Here are the installation steps.
http://brezular.com/2011/09/03/part1-openvswich-creating-and-submitting-openvswitch-extension-to-microcore-upstream/

And GNS3 labs are available here.
http://brezular.com/2011/06/25/part2-openvswich-vlans-trunks-l3-vlan-interface-intervlan-routing-configuration-and-testing/

[KVM and OVS] Installing KVM and Open vSwitch on Ubuntu

These articles provides a very good explanation about how to install KVM and Open vSwitch on Ubuntu.
http://blog.scottlowe.org/2012/08/17/installing-kvm-and-open-vswitch-on-ubuntu/
http://networkstatic.net/installing-open-vswitch-with-kvm/

I summarize the scripts from the above URLs as follows:
  • ### Installing KVM and Open vSwitch on Ubuntu ###
sudo apt-get update && apt-get dist-upgrade
sudo apt-get install kvm qemu-kvm libvirt-bin virtinst virt-manager
sudo virsh net-destroy default
sudo virsh net-autostart --disable default
sudo aptitude purge ebtables
  • ### Open vSwitch on Ubuntu ###
sudo apt-get install openvswitch-controller openvswitch-brcompat \
sudo openvswitch-switch openvswitch-datapath-source

# Edit this: /etc/default/openvswitch-switch and change this line:
  #BRCOMPAT=no ==> #BRCOMPAT=yes 

# to build and install the necessary module
sudo module-assistant auto-install openvswitch-datapath
  • ### Add Open vSwitch bridge ###
sudo ovs-vsctl add-br br0
sudo ovs-vsctl add-port br0 eth0
sudo ovs-vsctl list port
  • ### Change your eth0 IP to your new br0 interface ###
sudo ifconfig eth0 0
sudo ifconfig br0 192.168.1.x netmask 255.255.255.0
sudo route add default gw 192.168.1.1 br0

These two scripts bring up the KVM Tap interfaces into your
bridge from the CLI.

$ cat /etc/ovs-ifup
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1

$ cat /etc/ovs-ifdown
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1

#Then make executable
chmod +x /etc/ovs-ifup /etc/ovs-ifdown
  • ### BOOT HD IMG ###
Here are some KVM examples. Starting with the CD is easiest. No build needed for testing.

sudo kvm -m 1024 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown &
OS Install

sudo kvm -m 512 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /media/Storage/vm-images/CentOS-6.2-x86_64-LiveCD.iso &
CD Boot

sudo kvm -m 512 -net nic,macaddr=00:11:22:CC:CC:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /HD/Storage/vm-images/ubuntu-11.10-desktop-amd64.iso &
Make an Image from CD

sudo qemu-img create -f qcow2 /media/Storage/imgs/uCentOS-6.2.img 6G

Tuesday, December 3, 2013

[NSX] Network Visualization Gets Physical

In VMware NSX, how to let network visualization gets physical?
The answer is "Layer 2 Gateway Services". The physical switches have to implement the OVSDB and related APIs that communicate with NSX Controller so that they can provide the mapping of the segment in virtual network and VLAN in physical network. For more information in details, you can check out the following URLs.

http://networkheresy.com/2013/08/15/network-virtualization-gets-physical/


https://www.youtube.com/watch?v=QDOlggwyrVA&feature=c4-overview-vl&list=PLdYldEmmLm2lz5Bd0bzGCDKSULL52ytJT

Ivan's NSX Architecture Introduction, it is very good.
http://demo.ipspace.net/get/NSXArch

Tuesday, November 19, 2013

[OpenVNet] The introduction of OpenVNet

Why I pay attention to OpenVNet is because it uses Trema-Edge as OpenFlow 1.3 Controller to communicate with Open vSwitch 1.10. It gives us a great example to use Trema-Edge in Virtual Network Environment and learn more about some use cases. Please check out the following lists:

What is OpenVNet?
http://www.slideshare.net/akirayokokawa/openvnet

Offical Web Site:
http://openvnet.com/

Github Source:
https://github.com/axsh/openvnet

[Quagga] How to compile and install Quagga on Ubuntu 12.04

The following steps are the compilation and installation for Quagga on Ubuntu 12.04. Hopefully it is helpful for you.
  • Install all dependency(package) 
    • sudo apt-get build-dep quagga
  • Give the path for all configurations files and libraries used by quagga for starting. I use this one /opt/quagga .... and this is done by this comand: 
    • ./configure --enable-vtysh --prefix=/opt/quagga --localstatedir=/opt/quagga sysconfdir=/opt/quagga 
  • Create new folder: 
    • sudo mkdir /opt/quagga
  • Add new user : 
    • sudo adduser quagga 
  • Give the priviledge for the user quagga over the folder: /opt/quagga and for the folders and subfolders you give the privilegde for all rights : reading, changing and executing
    • sudo chown quagga:quagga /opt/quagga
    • sudo chmod 777 /opt/quagga 
  • Then you will be able to comiple Quagga: 
    • make
    • sudo make install 
Quagga configuration
--------------------
quagga version          : 0.99.22
host operating system   : linux-gnu
source code location    : .
compiler                : gcc
compiler flags          : -Os -fno-omit-frame-pointer -g -std=gnu99 -Wall -Wsign-compare -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wchar-subscripts -Wcast-qual
make                    : make
includes                : 
linker flags            :  -lcrypt   -lrt -lcap  -lm
state file directory    : /opt/quagga
config file directory   : /opt/quagga
example directory       : /opt/quagga
user to run as  : quagga
group to run as  : quagga
group for vty sockets : 
config file mask        : 0600
log file mask           : 0600

Now, let us try Quagga for some examples
  • Zebra
    • Copy sample to conf file:
      • cd /opt/quagga
      • cp zebra.conf.sample zebra.conf
    • Start zebra daemon, you use this command 
      • sudo /opt/quagga/sbin/zebra &
    • Check the daemon zebra:
      • netstat -a | grep zebra 
    • Get into the zebra, you use 
      • telnet localhost zebra
  • BGP
    • Copy sample to conf file:
      • cd /opt/quagga
      • cp bgpd.conf.sample bgpd.conf
    • Start bgpd: 
      • sudo /opt/quagga/sbin/bgpd &
    • Check the daemon zebra:
      • netstat -a | grep bgpd
    • Get into the bgpd, you use 
      • telnet localhost bgpd
  • vtysh
    • cd /opt/quagga
    • vi /opt/quagga/vtysh.conf
    • sudo /opt/quagga/bin/vtysh
! Sample configuration file for vtysh. ! !service integrated-vtysh-config hostname quagga-router username root nopassword !
Stop Quagga Daemon ( for example: bgpd ):
  • sudo kill `cat /opt/quagga/bgpd.pid`
Port Number:

  • zebra: 2601
  • ripd:  2602
  • ripng: 2603
  • ospfd: 2604
  • bgpd:  2605
  • ospf6d: 2606