Thursday, April 5, 2018

OpenvSwitch on BPi-R1 with Bananian

For my research project, I am using Banana Pi R1. It is an open-source router. The R1 has slim router form factor with a bay for 2.5" HDDs. It also has 4 Gigabit LAN ports, 1 Gigabit WAN, and 300Mbs wireless N capabilities.

I am using the Bananian 16.04 for the OS.



Before starting...

I assume that you all have installed OpenvSwitch either using package controller or building from source.

Since those 5 ports of R1 share a single interface, we will have to separate them by using VLAN.
The number of the ports goes like this:
3: WAN      4 0 1 2 : LAN
(From Left -> Right. Top view)

For the starter, to make sure that you have pointed your IP to your machine at /etc/hosts:

 127.0.01     localhost
 $Your IP     bananapi(Name for your machine)

 # The following......


Modify /etc/network/if-pre-up.d/swconfig:
#!/bin/sh
#---------------------------#
# BPI-R1 VLAN configuration #
#---------------------------#
#
# This will create the following ethernet ports:
# - eth0.101 = WAN (single port)
# - eth0.102 = LAN (4 port switch)
#
# You have to adjust your /etc/network/interfaces
#
# Comment out the next line to enable the VLAN configuration:
#exit 0

ifconfig eth0 up

# The swconfig port number are:
# |2|1|0|4| |3|
# (looking at front of ports)

swconfig dev eth0 set reset 1
swconfig dev eth0 set enable_vlan 1
swconfig dev eth0 vlan 101 set ports '3 8t'
swconfig dev eth0 vlan 102 set ports '4 8t'
swconfig dev eth0 vlan 103 set ports '0 8t'
swconfig dev eth0 vlan 104 set ports '1 8t'
swconfig dev eth0 vlan 105 set ports '2 8t'
swconfig dev eth0 set apply 1
Then you will need to update your interface configuration.
I am using eth0.101 as WAN to use as interface for controller and SSH. Also, I am using DHCP.

In my  /etc/network/interfaces
auto eth0.101
     iface eth0.101 inet dhcp

auto eth0.102
     iface eth0.102 inet manual

auto eth0.103
     iface eth0.103 inet manual

auto eth0.104
     iface eth0.104 inet manual

auto eth0.105
     iface eth0.105 inet manual
You might want to use ifup if you want to start the interface.
e.g.
service networking restart
ifconfig eth0.101 up

Adding Bridge and Port:
ovs-vsctl add-br br0
ovs-vsctl set-controller br0 tcp:[controller ip]:[port]
ovs-vsctl add-port br0 eth0.102
ovs-vsctl add-port br0 eth0.103
ovs-vsctl add-port br0 eth0.104
ovs-vsctl add-port br0 eth0.105
And there you have it!
Now you can add flow and run your application like iPerf ... etc


No comments:

Post a Comment

The Good, the Bad, and the Ugly of Working as a Software Engineer at AWS

After 5 incredible years at AWS, I have recently decided to join Zscaler. Working at Amazon Web Services is like being on a roller coaster y...