Installing and Configuring OpenvSwitch on Ubuntu 12.04 (Precise Pangolin)
Updates
- For installing OpenvSwitch on Ubuntu from package head to OpenvSwitch Configure from Packages and Attaching to a Floodlight OpenFlow Controller
- To install Open vSwitch from source head to Configuring VXLan and GRE tunnels on OpenvSwitch
- Or use this Python App I wrote to install some different combinations of tools. Last verified working June 2013. OpenFlow, OpenvSwitch and KVM SDN Lab Installation App
Installing and Configuring OpenvSwitch on Ubuntu 12.04 (Precise Pangolin)
Quick install how to for Installing and Configuring OpenvSwitch on Ubuntu 12.04 (Precise Pangolin) with the nightly OVS build. Before I start, I must point out the great progress the dev team has done in such a short time. All of the old gotchas in earlier releases on implementation are long gone. I am going to revisit the KVM integration in a few days as some of the inconsistencies for bringing up TAPs into hypervisors should be getting some consensus for provisioning.
The announcement of the inclusion of OpenvSwitch into the mainline Linux kernel, coupled with some KVM enhancements to provide VLAN tagging, LACP, QoS, sFlow etc, is making some of us excited ,and others very nervous.
1 2 3 4 5 6 7 8 9 10 11 |
@ubuntu-12:openvswitch-HEAD-f1936eb# uname -a Linux ubuntu-12 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux <em>#Ubuntu release</em> @ubuntu-12:openvswitch-HEAD-f1936eb# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu precise (development branch) Release: 12.04 Codename: precise |
For those familiar with the build you can just paste the following in your bash shell as root. To walk through the install skip the following snippet. The installation is extensively documented in the INSTALL file in the root of the tarball.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
apt-get update apt-get install -y git automake autoconf gcc uml-utilities libtool build-essential git pkg-config linux-headers-`uname -r` wget http://openvswitch.org/releases/openvswitch-1.10.0.tar.gz tar zxvf openvswitch-1.10.0.tar.gz cd openvswitch-1.10.0 ./boot.sh ./configure --with-linux=/lib/modules/`uname -r`/build make && make install insmod datapath/linux/openvswitch.ko mkdir -p /usr/local/etc/openvswitch ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema ovsdb-server -v --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 \ --pidfile --detach --log-file ovs-vsctl --no-wait init ovs-vswitchd --pidfile --detach ovs-vsctl show |
System Preperation
Install dependencies:
1 2 3 4 |
apt-get update apt-get install python-simplejson automake autoconf gcc uml-utilities libtool build-essential git pkg-config |
Download the OVS tarball Note: you can also pull from the git repository but that is bleeding edge and depending on kernel releases it may need some massaging.
1 2 3 4 5 |
wget http://openvswitch.org/releases/openvswitch-1.10.0.tar.gz tar zxvf openvswitch-1.10.0.tar.gz cd openvswitch-1.10.0 |
Compiling Open vSwitch From Source
1 2 3 4 5 6 7 8 |
./boot.sh ./configure --with-linux=/lib/modules/`uname -r`/build make make install #Load the OVS Kernel Module insmod datapath/linux/openvswitch.ko |
1 2 3 4 5 6 |
#If you are running a stripped version of Nix like an EC2 cloud image and get an error along the lines of this: configure: error: source dir /lib/modules/3.2.0-23-virtual/build doesn't exist #Pull down the headers for your kernel. sudo apt-get install linux-headers-`uname -r` |
Open vSwitch Configuration
1 2 3 4 5 |
touch /usr/local/etc/ovs-vswitchd.conf mkdir -p /usr/local/etc/openvswitch ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema |
Run the following commands, note some dashes are two ‘- -‘ e.g. – -remote=db & – -private-key
Start ovsdb-server, this stores the config into a file that is persistent even after restarts.
1 2 3 4 5 6 7 8 |
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 |
1 2 3 4 5 6 7 8 9 10 |
#Only need to run this the first time. ovs-vsctl --no-wait init #Start vswitch ovs-vswitchd --pidfile --detach #Verify the kernel module(s) in case you didn't earlier and get errors. #lsmod | grep br #brcompat 13512 0 #openvswitch 98196 1 brcompat |
If they are not there try loading again and check your path to the kernel module.
1 2 3 |
insmod datapath/linux/openvswitch.ko |
At this point you have a fucntioning vanilla OVS install. Output should look something like this.
1 2 3 4 5 6 7 |
ovs-vsctl show b6d574d7-5582-4cc0-93e5-a90cf0eb0a38 root@demo-139:/home/ubuntu/ovs-vxlan# ovs-vsctl --version ovs-vsctl (Open vSwitch) 1.8.90 Compiled Aug 19 2012 06:23:36 |
Configure Linux Networking
I have one NIC (eth1) on the same LAN segment/network/vlan.
We are attaching eth1 to br1 and applying an IP to the bridge interface.
We are attaching an IP to br2. br2 is the island that we are building a tunnel for hosts to connect on.
1 2 3 4 5 6 7 8 9 |
ovs-vsctl add-br br1 ovs-vsctl add-br br2 ovs-vsctl add-port br1 eth1 ifconfig eth1 0 ifconfig br1 192.168.1.11 netmask 255.255.255.0 route add default gw 192.168.1.1 br1 (br1 is now the default gateway NIC instead of eth1 since we moved eth1 inside of br1 (bridge interface br1) ifconfig br2 10.1.2.11 netmask 255.255.255.0 (no physical interface is bound here.) |
If you have issues getting the bridge built you may need to kill the OVS processes and restart them depending on your step order.
Your Linux routing table should now look something like this:
1 2 3 4 5 6 7 8 |
root@openstack2:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 br1 10.1.2.0 0.0.0.0 255.255.255.0 U 0 0 0 br2 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br1 |
You can put the following into a text file and give it execute permissions with “chmod +x filename” and then run it “./filename”. If your network settings are right it should flip the IP to the bridge and not cut you off. Keyword “should” so have a way to get to the box if you cut yourself off.
1 2 3 4 5 6 7 8 |
ovs-vsctl add-br br1 ovs-vsctl add-br br2 ovs-vsctl add-port br1 eth1 ifconfig eth1 0 && ifconfig br1 192.168.1.(X) netmask 255.255.255.0 route add default gw 192.168.1.1 br1 ifconfig br2 10.1.2.11 netmask 255.255.255.0 |
If you want your networking to be persistent over restart you can adjust /etc/network/interfaces similar to the following template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
auto br0 iface br0 inet static address 192.168.1.x network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 #Add your physical interface to the bridge. bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off dns-nameservers 8.8.8.8 |
Thanks for stopping by.
Remove bridge-utils removes:
The following packages will be REMOVED:
bridge-utils libvirt-bin python-vm-builder qemu qemu-common qemu-kvm
ubuntu-vm-builder
And I am quite sure I need some of those packages for my VM’s. Namely the ubuntu-vm-builder.
Are you sure that removing bridge-utils and related packages won’t crash my virtual machines? Or not allow kvm to work correctly?
Hi Matt. I will test in a bit. That’s a good point. ‘rmmod bridge’ will pull the Linux bridging module to get you going. I will get back to you after work.
Hi,
I had a question. Why are we stopping the network-manager in this installation? Should we start the network-manager after the installation is done ?
I tend to just because it can get in the way with some things. If you install Ubuntu Server addition it wouldn’t be installed anywho. /etc/network/interfaces is the file the loads the config on a base intall. Not required but may get in the way.
Cyas.
I have one NIC (eth1) on the same LAN segment/network/vlan.
We are attaching eth1 to br1 and applying an IP to the bridge interface.
We are attaching an IP to br2. br2 is the island that we are building a tunnel for hosts to connect on.
Does the above mean that before adding bridges using ovs-vsctl you have one ethernet interface eth1 with ip 192.168.1.1? I have a similar situation.but after the operations you suggested I can ping host and other machines in the host network but not google. (maybe DNS is trashed.??) any thoughts?
stop and purge the network-manager could become a nightmare. In my case, i lost network access completely. it toke me hours to recover from the disaster.
Hi Brent,
I am running my ovsdb-server on the TCP port and not on the unix server domain socket as discussed above. The problem I am facing is , I am unable to launch any VM. It is giving error “Connection Refused”. Any input?
Thnx
Hi,
I am trying to install openvswitch on ubuntu using this tutorial but I am struck in the COMPILING OPEN VSWITCH FROM SOURCE section at the following command:
./configure –with-linux=/lib/modules/uname -r/build
It says -r/build option doesn’t exist. When I remove the -r/build part from above command, it says no such directory exists. When I looked into the lib folder, there is no directory named modules inside the lib folder.
I am trying it on Ubuntu 12.10.
Hi Michael, on the road at the moment but I copy and pasted the build the other day.
Wondering if it is a syntax formatting problem in the post maybe.
There are backticks in the syntax. Try this:
./configure –with-linux=/lib/modules/`uname -r`/build
.
apt-get install -y git python-simplejson python-qt4 python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential git pkg-config linux-headers-`uname -r`
git clone git://openvswitch.org/openvswitch
cd openvswitch
./boot.sh
./configure –with-linux=/lib/modules/`uname -r`/build
make && make install
insmod datapath/linux/openvswitch.ko
touch /usr/local/etc/ovs-vswitchd.conf
mkdir -p /usr/local/etc/openvswitch
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
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
ovs-vsctl –no-wait init
ovs-vswitchd –pidfile –detach
ovs-vsctl show
http://networkstatic.net/configuring-vxlan-and-gre-tunnels-on-openvswitch/
Just lemme know if that doesn’t work and I will verify it tonight.
Regards,
-Brent
It’s the same error coming up. I am using Ubuntu 12.10.
The command that worked for me is from opemvswitch Install readme file:
./configure –with-linux=/lib/modules/`uname -r`/build
Hi,
I am trying to install OpenVSwitch in the physical machine. Previously I have used the GENI testbed and in GENI VMs the above mentioned steps worked without any errors. But when I am trying to install the OVS in user space, then I am getting error when I am trying to “make”.
Then I tried with OVS-2.1.0., well with this everything is fine up to “make && make install”, when I am trying to insert the modules in the kernel its giving some error, (Unknown symbol in module). Do I need to insert the modules in the kernel? How to resolve this problem.
Thank you for your time.
Regards
Bustam
Hi Bustam,
$ ./configure –with-linux=/lib/modules/`uname -r`/build
$ make && make install
$ make modules_install
$ lsmod | grep open
If the kernel modules aren’t loaded try
$ modprobe openvswitch
Ive noticed insmod doesn’t do the trick anymore but haven’t had time to poke around. I know this works on Fedora 19/20. Course you can install from package with yum / apt. Fedora is v2.x+. On ubuntu you can probably find a back port to 2.0 i would hope.
Thanks!
-Brent
Hi,
I am trying to install Openvswitch on Ubuntu 12.10 and when I used the second command of installing dependencies i.e.:
apt-get install python-simplejson python-qt4 python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential git pkg-config
I got the following error:
Setting up openvswitch-pki (1.4.3-0ubuntu2.1) …
/usr/local/bin/ovs-pki: /usr/local/var/lib/openvswitch/pki already exists and –force not specified
dpkg: error processing openvswitch-pki (–configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of openvswitch-controller:
No apport report written because the error message indicates its a followup error from a previous failure.
openvswitch-controller depends on openvswitch-pki (= 1.4.3-0ubuntu2.1); however:
Package openvswitch-pki is not configured yet.
dpkg: error processing openvswitch-controller (–configure):
dependency problems – leaving unconfigured
Errors were encountered while processing:
openvswitch-pki
openvswitch-controller
E: Sub-process /usr/bin/dpkg returned an error code (1)
What could be possibly wrong?
Thank you.
Hi,
When I am trying to run this command:
sudo insmod datapath/linux/openvswitch.ko
It’s saying the following error:
~/ovs-vxlan$ sudo insmod datapath/linux/openvswitch.ko
insmod: error inserting ‘datapath/linux/openvswitch.ko’: -1 File exists
Also, when I try to run sudo lsmod | grep br command, I am getting this output:
bridge 90447 0
stp 12977 1 bridge
llc 14553 2 bridge,stp
Can you tell me how to fix it?
Thanks for your documentation above.. However I have Question.. May I leave my question ont this?
My Questions are blow..
[ 379.578038] openvswitch: Unknown symbol gre_del_protocol (err 0)
[ 379.578069] openvswitch: Unknown symbol gre_add_protocol (err 0)
Because of this, I can not insert module… I am using Ubuntu12.04 LTS (Server) which is downloaded on wetsite..
Please let me know.. Help me..
Hi Jun, I am getting the same thing. I noticed Ben Pfaff posted the same occourance last week. He is one of the lead devs on OVS so I would imagine there is a bug open but if not checking the OVS dev LSV might be warranted. I haven’t dropped back to an older build but may try.
http://comments.gmane.org/gmane.network.openvswitch.devel/22049
Cheers.
-Brent
Thanks for your url-link ….. It was helpful for me… so much
Also, I have found the answer from http://git.openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL;hb=HEAD
% make modules_install
% /sbin/modprobe openvswitch
is same thing..
Thanks alot.
I wasn’t paying attention and missed kernel 3.9.8. I’d say within a week or two things will catch up to the new release. In the meantime you can pull the binary or use an older kernel.
Cheers,
-Brent
Hi! I’ve got a problem with `ovsdb-server` command. It rises an error:
ovsdb-server: “db:Open_vSwitch,manager_options”: invalid syntax
What is wrong with my installation? I have rechecked manual, the syntax seems to be correct.
Hi, Ilya
I encountered same error.
And maybe this is a bug of ovs with ubuntu 12.04.
https://bugs.launchpad.net/ubuntu/+source/openvswitch/+bug/1203806
I can install ovs with version 1.9
By the way, I use Ubuntu 12.04 server. Sorry for double comment.
Hi,
I am facing an issue. When my ovs try to connect to floodlight , there is no any problem.But in case of opendaylight,it tries to connect to it regularly, but fails. Can u please suggest the reasons?
Hi,
Excellent installation guide, thank you!
I cloned the latest openvswitch git repo, but I’m getting an error while trying to do:
‘sudo insmod datapath/linux/openvswitch.ko’
From /var/log/syslog:
‘Oct 8 10:48:38 DavGDev kernel: [ 4279.417176] openvswitch: Unknown symbol crc32c (err 0)’
I’m using Ubuntu12.04LTS:
‘Linux DavGDev 3.2.0-54-generic-pae #82-Ubuntu SMP Tue Sep 10 20:29:22 UTC 2013 i686 i686 i386 GNU/Linux’
I had the missing gre symbol and fixed it by doing:
‘sudo modprobe gre’
but I don’t know which module, if any, will fix crc32c symbol…
Any ideas?
Thanks,
Dave
were you able to fix it ?
Hi,
when i try to do:
ovs-vsctl –no-wait init
It says:
2013-10-10T13:41:06Z|00002|reconnect|WARN|unix:/usr/local/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
ovs-vsctl: unix:/usr/local/var/run/openvswitch/db.sock: database connection failed (No such file or directory)
So i have done:
ps -Af | grep ovsdb-server
to check the daemon ann it says:
root 28570 28553 0 15:20 ? 00:00:00 ovsdb-server
root 28663 28650 0 15:22 pts/3 00:00:00 grep –color=auto ovsdb-server
What i should do? Can you help me?
Thank you very much!
Hi David, give installing from tarball a shot and see if that improves the errors and let me know. If not ping me on IRC.
Cheers,
-Brent
I ran into issues building from source on Ubuntu 13.04+ in the past week or so. The specific error is: ### “db:Open_vSwitch,manager_options : invalid syntax” ###
For now I pulled cloning from the how-to and opt for the tarball. If you want to pull from git use:
git clone git://git.openvswitch.org/openvswitch
Cheers,
-Brent
Hi Brent,
Thank you for the post. This post helped me in setting up openvswitch on my linuxbox.
Now my switch node has 4 interfaces. 1 to controller and other 3 to hosts.
This is running on my controller
./pox.py openflow.of_01 –address=10.1.2.2 –port=6633 log.level –DEBUG misc.of_tutorial
On the switch:
ovs-vsctl add-br br1
ovs-vsctl add-port br1 inf002
#inf002 is the interface on Switch connecting to the controller node
# remove the IP of inf002 and put it on the newly created br1 interface pointing to controller
ifconfig inf002 0
ifconfig br1 10.1.2.1 netmask 255.255.255.0
ovs-vsctl set-controller br1 tcp:10.1.2.2:6633
This made the connection to the controller. The log said connected at the controller screen with the DPID.
Now I am unsure about the hosts facing configuration of the br interface on switch. Please help.
Hi Mr Brent,
When I am trying to run this command:
sudo insmod datapath/linux/openvswitch.ko
It’s saying the following error:
insmod: error inserting ‘datapath/linux/openvswitch.ko’: -1 Unknown symbol in module
can u help me to fix it ?
thx
Which version of openVswitch are you trying to install ?
post your ovs version, kernel version
and output of “dmesg |tail ” when you are trying to do insmod.
Hi G8XSU, thx for ur attention.
I try to install OPenVSwitch-2.0.0 on VirtualBox (Ubuntu-12.04-Desktop-i386) .
I used 3.2.0-58-generic-pae
This is the output when i wrote ‘sudo dmesg |tail’
amha@amha-VirtualBox:~/openvswitch-2.0.0$ sudo dmesg |tail
[ 20.100152] fb0: VESA VGA frame buffer device
[ 21.269151] init: anacron main process (802) killed by TERM signal
[ 22.204054] init: plymouth-upstart-bridge main process (498) killed by TERM signal
[ 28.168183] eth0: no IPv6 routers present
[ 707.476130] openvswitch: Unknown symbol gre_del_protocol (err 0)
[ 707.476130] openvswitch: Unknown symbol gre_add_protocol (err 0)
[ 707.476130] openvswitch: Unknown symbol crc32c (err 0)
[ 1291.512179] openvswitch: Unknown symbol gre_del_protocol (err 0)
[ 1291.512179] openvswitch: Unknown symbol gre_add_protocol (err 0)
[ 1291.512179] openvswitch: Unknown symbol crc32c (err 0)
sudo modprobe gre
sudo modprobe crc32c
🙂
still error (not work) 🙁
I have just tried to install the openvswitch on the ubuntu 12.04.My ubuntu version is 12.04.4,I have tried openvswitch 1.9.*,openvswitch1.10.0,when I make it,the make program report error:”
/opt/openvswitch-1.9.3/datapath/linux/actions.c:104:2:error:too few arguments to function ‘_vlan_hwaccel_put_tag’
include/linux/if_vlan.h:236:31:note:declared here
/opt/openvswitch-1.9.3/datapath/linux/actions.c:In function ‘push_vlan’:
/opt/openvswitch-1.9.’3/datapath/linux/action.c:124:2:error:too few arguments to function ‘_vlan_hwaccel_put_tag’
include/linux/if_vlan.h:236:31:note:declared here
the error reported by installing openvswitch 1.10.0 is the same.
I am facing issues while installing openvswitch any versions…even after complete cleanup and things
db:Open_vSwitch,manager_options”: Invalid Syntax
Tried several installations but it doesn’t worked. Did anyone face issues??
Hi Brent,
i just want to ask you that , can we configure OVS(OpenvSwitch) or any openFlow switch act as a router. and if yes how ?
i am doing my final semester university project on SDN , where i have to create topology using some openVswitches and using SDN controller make OpenvSwitch act as a router .
can you please share some idea on how i can achieve this Senior.
can we configure OpenvSwitch as router ?
thanks