Friday, January 6, 2012

Openvswitch with Virtualbox

This tutorial assume that you already configured openvswitch on virtualbox host machine.

Create the virtual switch on the host machine:
ovs-vsctl add-br lan0
Now we have a virtual switch called lan0 :)

Next we create tap devices on the host machine so we can bind them to the guests laters.
for tap in `seq 0 15`; do
        ip tuntap add mode tap lan0p$tap
done;
# check if the interfaces are there
ip tuntap list

Bring the tap interfaces up:
for tap in `seq 0 15`; do 
        ip link set lan0p$tap up
done;

# check if the interface are up
ip link

Now we use ovs-vsctl to "bind" the tap devices to "lan0" switch
for tap in `seq 0 15`; do
        ovs-vsctl add-port lan0 lan0p$tap
done;

# see that the tap devices are mapped to ports in lan0
ovs-vsctl list-ports lan0

Now we have 16 ports switch called lan0 with 16 tap interfaces binded to lan0 virtual switch.

Next thing is to connect virtualbox guests to it:

I assume you are using the GUI for this so under the network setting select in "Attached to" "Bridge Adapter" and in "Name" select "lan0p1" for port number 1 in the switch.

Repeat this action for each guest you want to connect to the switch.

Now your virtual machines has a virtual network ;)

Enjoy !

Golan

3 comments:

Anonymous said...

Thank you, this was extremely helpful.

Gilbert Standen said...

Hi Golan,

To say this was extremely helpful post is an understatement. I built on your work here and extended it to openvswitch config with 2 redundant switches connected by bonded switch vports with 2 Oracle RAC node bonded private interconnect connected criss-cross over the switches with the bonded vport interswitch link as the "pathway of last resort" so to speak. Here is my howto:

http://thecomingstorm.us/smf/index.php?topic=323.0

Golan Zakai said...

Hey Gilbert,

I am very happy that my post helped ya, nice work with the dual switch + bonding !

Golan