0
  • I have 3 Ubuntu Server VMs on VirtualBox with static IPs on eth1 interface:

192.168.56.2

192.168.56.3

192.168.56.4

I have chosen Adapter 1 as NAT and Adapter 2 as Host Only for all VMs

  • Now to enable Internet on VMs from Host, I made Adapter1 NAT and on one VM I added line in /etc/networks/interfaces to assign static IP as:

    auto eth1
    iface eth1 inet static
    address 192.168.56.2
    netmask 255.255.255.0
    

After adding this for one VM internet works fine.

  • But now to enable Internet along with internal network on other VMs I added following on other 2 VMs.

For 192.168.56.3 --->

   auto eth1
    iface eth1 inet static
    address 192.168.56.3
    netmask 255.255.255.0
    gateway 192.168.56.2

For 192.168.56.4 --->

   auto eth1
    iface eth1 inet static
    address 192.168.56.4
    netmask 255.255.255.0
    gateway 192.168.56.2

Becuase of above two entries I am able to ping all of the VMs to each other, as I have added 192.168.56.2 as a gateway for other two VMs.

But internet is only accessible from 192.168.56.2 VM, And other 2 VMs are not able to talk to internet.

I do not know what i am missing here, kindly help.

Thanks in Advance !!

5
  • You should bridge them.
    – rowan
    Mar 30, 2016 at 17:54
  • you mean, i have to make Bridged Adapter instead of NAT on all them.
    – Pert8S
    Mar 30, 2016 at 18:08
  • Yeah, that would resolve your issue. You can still configure their own IPs / network but then by your own router.
    – rowan
    Mar 30, 2016 at 18:10
  • I tried removing the gateway from eth1 interface, and now I am able to access internet on all of them. Along with internal reachability. :)
    – Pert8S
    Mar 30, 2016 at 18:16
  • Ah, yeah - sounds logical when I reread your interfaces. Cheers!
    – rowan
    Mar 30, 2016 at 18:19

1 Answer 1

2

Your solution should be bridging.

This article of virtualbox has all the information needed.

Browse to 6.5 for Bridged networking

With bridged networking, VirtualBox uses a device driver on your host system that filters data from your physical network adapter. This driver is therefore called a "net filter" driver. This allows VirtualBox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.

You must log in to answer this question.

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