I'm using Open vSwitch to create a switched network between virtualBox guest machines, and i want that the host OS (Ubuntu 12.04) join this network and to configure it as the gateway of this virtual network:

First, i created a vswitch and i added ports to tap devices (that virtual machines use them as bridged interfaces):

ovs-vsctl add-br sw0
ovs-vsctl add-port sw0 tap0

After that, i set statically the ip of Lubuntu 12.04 virtual machine :

ifconfig eth0 up
route add -net gw

In the host os side, i also set the ip address :

ifconfig sw0 up

At this time, i can ping from Lubunut to Ubunutu. I want now, in the host machine to use IP masquerade to forward traffic from network to my physical interace (connected to Internet) :

sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth1 -s -j MASQUERADE

So from Lubuntu (the virtual machine), i can ping the Ubuntu eth1 interface, but i cannot reach the real network (e.g: the gateway on real LAN), i have tried :

nslookup google.com
dig @ yahoo.com
dig @ google.com

Network Topology

   Internet (real gw) ------ Host OS -------- vswitch -------- VBox Guest 1
    ip masquerade
                                                 ------------ VBox Guest 2
  • Please add any progress if you had. I have the same problem.
    – Masood_mj
    Oct 9, 2014 at 15:48

2 Answers 2


The answer is not really mine, but... Try following Open vSwitch on VirtualBox

There was also a brief text file from some Fedora people on similar subject: libvirt and OpenVSwitch in a form of text file... wasn't able to locate it though.

as per comment, here's short summary:

(1) Create vnet0 interface and br0 bridge:

ovs-vsctl add-br br0
ip tuntap add mode tap vnet0
ip link set vnet0 up
ovs-vsctl add-port br0 vnet0
ip link # (View the created interface)

(2) spin up VM that uses vnet0 interface (as a bridged adapter)

(3) connect bridge br0 to real network:

ovs-vsctl add-br br0 
ovs-vsctl add-port br0 eth0 
ovs-vsctl add-port br0 vnet0 
ifconfig eth0  0 && ifconfig br0 192.168.1.(X) netmask
route add default gw br0
route del default gw eth0
  • Since you are linking to an external article which may change, it is recommendable to summarize the solution in your answer and reference the article instead. Apr 6, 2015 at 6:57

Enable forwarding upon reboot by un-commenting these lines in /etc/sysctl.conf:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .