This document will explain how to use Open Source Software Switch, called as Open vSwitch for providing network connection between Virtual Machine inside the VirtualBox virtualization platform.
x
Component Used
1. Ubuntu Linux 12.04 LTS (Precise Pangolin)
2. VirtualBox Software 4.2 (downloaded from Ubuntu Repository Server)
3. Open vSwitch Software Switch 1.4 (Installed from Ubuntu Repository Server)
x
Installation VirtualBox
VirtualBox can be installed very easy using aptitude tool from Ubuntu Repository Server.
aris@djogja:/opt$ sudo apt-get update aris@djogja:/opt$ sudo apt-get install dkms aris@djogja:/opt$ sudo apt-get install virtualbox-4.2If there is any error because of signatures error from VirtualBox website
W: GPG error: http://download.virtualbox.org precise InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 54422A4B98AB5139So, the key need to be install manually using this command below.
aris@djogja:/opt$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add –After key installation success, please repeat DKMS and VirtualBox installing command
x
Installation of Open vSwitch
Open vSwitch also can be installed very easily through Ubuntu Repository Server using aptitude tools. There are some mandatory packages need to be install but there are some additional fitur which can be installed to utilize the Open vSwitch. The mandatory package such as Open vSwitch datapath can be installed using this following command.
aris@djogja:/opt$ sudo apt-get install openvswitch-datapath-source bridge-utils aris@djogja:/opt$ sudo module-assistant auto-install openvswitch-datapathIn order to enhance the functionality of the Open vSwitch some additional packages can be installed such as “openvswitch-brcompat” for linux bridge compatibility configuration and “openvswitch-controller” for adding controller function in the same hosts.
aris@djogja:/opt$ sudo apt-get install openvswitch-brcompat openvswitch-common openvswitch-controllerAfter the installation finish, the controller will be automatically run using default TCP port number and certificate.
x
Open vSwitch (Bridge) Configuration
The first step to configure the switch is preparing the datapath or bridge for virtual interfaces from the virtual machines. These following commands will create datapath or bridge called as “br1” and virtual interface called as “vnet0”.
aris@djogja:/opt$ sudo ovs-vsctl add-br br1aris@djogja:/opt$ sudo ip tuntap add mode tap vnet0
aris@djogja:/opt$ sudo ip link set vnet0 up
aris@djogja:/opt$ sudo ovs-vsctl add-port br0 vnet0
aris@djogja:/opt$ sudo ifconfig br1 up
Make sure the datapath or bridge and interfaces are up using these following commands.
aris@djogja:/opt$ sudo ip link1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:26:6c:85:d6:e1 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether e8:39:df:c5:ae:e0 brd ff:ff:ff:ff:ff:ff
…. 15: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
link/ether 92:91:cd:57:bc:4f brd ff:ff:ff:ff:ff:ff
16: vnet0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 500
link/ether 76:94:b8:8e:e1:da brd ff:ff:ff:ff:ff:ff aris@djogja:/opt$ ifconfig
br1 Link encap:Ethernet HWaddr 92:91:cd:57:bc:4f
inet6 addr: fe80::9091:cdff:fe57:bc4f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:4694 (4.6 KB) eth0 Link encap:Ethernet HWaddr 00:26:6c:85:d6:e1 UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:43 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:407456 errors:0 dropped:0 overruns:0 frame:0
TX packets:407456 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:846803394 (846.8 MB) TX bytes:846803394 (846.8 MB) vnet0 Link encap:Ethernet HWaddr 76:94:b8:8e:e1:da UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr e8:39:df:c5:ae:e0
inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ea39:dfff:fec5:aee0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:636440 errors:0 dropped:0 overruns:0 frame:0
TX packets:613058 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:712913720 (712.9 MB) TX bytes:93192778 (93.1 MB) aris@djogja:/opt$ sudo ovs-vsctl show
cdf41e3a-b0a8-4251-ae8c-bc0ab323bfba
Bridge “br1”
Port “br1”
Interface “br1”
type: internal
Port “vnet0”
Interface “vnet0”
Port “eth0”
Interface “eth0”
ovs_version: “1.4.0+build0”
In order to test connectivity between the virtual switch with the virtual machine, put IP address on the datapath or bridge interfaces (acting as management IP address)
aris@djogja:/opt$ sudo ifconfig br1 172.16.1.1 netmask 255.255.255.0 upx
Virtual Machine Configuration
There is no special configuration for the virtualbox virtual machine, except selecting the proper interface for “Bridged Adapter” for Virtual Machine “Network Adapter”. For selecting the interface, use the virtual machine “Settings” and choose the “Network” in the left pane. Then give check mark on the “Enable Network Adapter”, select “Attached to : Bridged Adapter” and then select the name which already defined in the previous section “vnet0”.
Click “OK” and the run the virtual machine. In order to test the connection give the IP address on the network interface of the virtual machine with the IP address from the same segment (172.16.1.0/24).
aris@djogja:/opt$ sudo ifconfig eth4 172.16.1.2 netmask 255.255.255.0 up
x
Connectivity Testing
Testing can be done by sending ICMP packet (Pinging) from the Open vSwitch to the Virtual Machine or vice versa.
x
Reference
1. Open vSwitch on Virtual Box