# VM Created is unable to connect internet by using openvswitch

**URL:** <https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615>\
**Category:** Product Support\
**Created:** [January 21, 2017, 12:20pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615 "2017-01-21T12:20:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 21, 2017, 12:20pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/1 "2017-01-21T12:20:33Z")

</div>

Front end and node on same machine  
–version 5.2

OS-- Ubuntu 14.04 LTS  
any how i need to connect vm to internet …no matter to use openvswitch  
both vm and host must ping with each other

any thoughts on solution  
thank you…

---

<div class="post-metadata">

**Author:** ![Bent\_Haase](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/bent_haase/32/4998_2.png) [@Bent\_Haase](https://forum.opennebula.io/u/Bent_Haase)\
**Post date:** [January 21, 2017, 3:11pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/2 "2017-01-21T15:11:32Z")

</div>

Not 100% sure (by your question) if you want to use [Open vSwitch](http://openvswitch.org/) or not but the easiest method is to setup a [virtual network](http://docs.opennebula.org/5.2/operation/network_management/manage_vnets.html) connected to a bridge on the host.

That will allow each VM which is deployed on that virtual network in OpenNebula to reach the network as well as ping the host (node).

[Here is some information](https://wiki.debian.org/BridgeNetworkConnections) about Debian and network bridges (assuming you use either Ubuntu or Debian as a guest)

Make sure to either provide a dhcp server for the virtual network or setup the correct ip / netmask and gateway manually in the guest.

---

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 21, 2017, 5:19pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/3 "2017-01-21T17:19:57Z")

</div>

ok i will try for it and get you soon …  
thank you so much for your reply

---

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 22, 2017, 7:02am UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/4 "2017-01-22T07:02:09Z")

</div>

I created br0 as bridge network and added it the eth0  
but by doing this only vm is connected to internet not the host .

thank you…

---

<div class="post-metadata">

**Author:** ![Bent\_Haase](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/bent_haase/32/4998_2.png) [@Bent\_Haase](https://forum.opennebula.io/u/Bent_Haase)\
**Post date:** [January 22, 2017, 10:08am UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/5 "2017-01-22T10:08:52Z")

</div>

Okay sounds not too bad yet!

On the host (“the physical machine”) the bridge configuration should look something like this:

```
# The primary network interface
auto br0
iface br0 inet static
	address 1.2.3.4
	netmask 24
	gateway 1.2.3.1
	dns-nameservers 8.8.8.8
	bridge_ports eth0
	bridge_fd 0

```

Make sure to change the IP addresses according to your network. In this example I used googles DNS servers which is in most cases a good option.

After editing your `interfaces` config like stated above you should reboot your server (easiest option). After a reboot, you should be able to connect to the internet from your host (try `ping google.com`).

In OpenNebula your virtual network may look something like this:

 ![](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/4/4591693a98cab98c1d0b56c1e18c46b77402b5fa.png)

---

<div class="post-metadata">

**Author:** ![feldsam](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/feldsam/32/4441_2.png) [@feldsam](https://forum.opennebula.io/u/feldsam)\
**Post date:** [January 22, 2017, 11:06am UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/6 "2017-01-22T11:06:32Z")

</div>

Hi, as Bent\_Haase said, you need to configure IP address and gateway on br0 interface, you just copy that from eth0 interface.

---

<div class="post-metadata">

**Author:** ![Bent\_Haase](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/bent_haase/32/4998_2.png) [@Bent\_Haase](https://forum.opennebula.io/u/Bent_Haase)\
**Post date:** [January 22, 2017, 1:33pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/7 "2017-01-22T13:33:07Z")

</div>

And remove the config for the eth0 interface, else wise the server would have two gateways / tries to configure both virtual interfaces on one physical interface.

---

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 22, 2017, 5:56pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/8 "2017-01-22T17:56:44Z")

</div>

Thanks a lot… both host and vm are pinging with each other  
but when i restart machine each time i have to add br0 with eth0 after configuring interface file with br0 as said by Bent.

thank you once again.

---

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 22, 2017, 6:05pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/9 "2017-01-22T18:05:33Z")

</div>

Thank you Sir  
both host and vm are pinging with each other .  
only thing is that each time after machine restarts i have to add the br0 and eth0  
by cammands ( " brctl addbr br0 AND brctl addif br0 eth0").  
i have configured the /etc/network/interface file as you said with only br0 .  
vm is connected to internet and host isn’t connected  
but both are pinging…  
thank you once again

---

<div class="post-metadata">

**Author:** ![Bent\_Haase](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/bent_haase/32/4998_2.png) [@Bent\_Haase](https://forum.opennebula.io/u/Bent_Haase)\
**Post date:** [January 22, 2017, 8:36pm UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/10 "2017-01-22T20:36:56Z")

</div>

What OS are you using? (CentOS 7 ? Ubuntu 16.04.1? Debian? …?)

if you don’t mind, post your `/etc/network/interface` here.

---

<div class="post-metadata">

**Author:** ![sachi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sachi](https://forum.opennebula.io/u/sachi)\
**Post date:** [January 23, 2017, 5:25am UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/11 "2017-01-23T05:25:38Z")

</div>

both vm as well as host are having ubuntu 14.04  
and here is my inteface file  
[interfaces](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/5/50e43bc99005105eee907bf16c16ea0150debc70) (240 Bytes)

my host IP is 192.168.0.20 …selected manual method for wired connection

---

<div class="post-metadata">

**Author:** ![Bent\_Haase](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/bent_haase/32/4998_2.png) [@Bent\_Haase](https://forum.opennebula.io/u/Bent_Haase)\
**Post date:** [January 24, 2017, 10:16am UTC](https://forum.opennebula.io/t/vm-created-is-unable-to-connect-internet-by-using-openvswitch/3615/12 "2017-01-24T10:16:59Z")

</div>

Looking all good so far, after a reboot your host should be able to connect to the internet (if your router is configured properly and allows outgoing connections/servers as a gateway).

Your VM connected to the br0 interface should also be able to connect to the internet.

If neither of them is able to connect to the internet, check your router / check if your servers (hosts) IP `192.168.0.20` is not used somewhere else (for example in a VM). I suggest putting the hosts IP on hold in OpenNebulas virtual network settings to avoid it being allocated.

Except that, my setup is working with basically the same settings, host and VM’s being able to interconnect and connect to the internet.
