Ubuntu – Two guest in one NAT range (virtualbox)

nat;virtualbox

I have two VMs(Ubuntu) in virtualbox and I wanna assign the first one 10.0.3.15 and the other one 10.0.3.14. But when I set network type to NAT the network adresses are different, 10.0.3.15 and 10.0.4.15.

Even when I change the range, one of them to another one statically in Ubunutu I can not ping another one.

I could not find any solution over the Internet!

Best Answer

NAT mode will not let you do that. In this mode:

The "router", in this case, is the VirtualBox networking engine, which maps traffic from and to the virtual machine transparently. In VirtualBox this router is placed between each virtual machine and the host. This separation maximizes security since by default virtual machines cannot talk to each other.

Note there's an isolation between each virtual machine, so they will be unable to connect to each other.

What you need is to configure your virtual machines (go to settings, network, look at the network modes) to use either internal networking or host-only networking.

Internal networking will allow virtual machines to communicate only with other virtual machines. Host-only networking will also allow VMs to communicate with the host system.

Read here about what each mode does and how to configure them:

http://www.virtualbox.org/manual/ch06.html

  1. configure both your virtual machines' networks to be "Internal network". Select "eth0" for "attached to" (this means the VM's network interface that will be connected to this network) and select the same "name" for the network (think of each name as a "hub" to which virtual machines are connected). The default of intnet is fine.
  2. Boot your VMS, and manually assign IP addresses. I tried with 10.0.0.1 for one and 10.0.0.2 for the other.
  3. You should be able to ping 10.0.0.1 from 10.0.0.2. It works for me!