how to make 2 virtualbox vms able to see each other via internal network but also be able to access the internet

I solved it by adding 2 adapters on each VM. One for NAT and one for Host-only Adapter Network.

On the NAT I configured port forwards from 2201 to 22 etc. And when the VMs booted I had to configure their internal static IPs. They VMs are ubuntu so I had to edit /etc/network/interfaces and add:

auto eth1
iface eth1 inet static
address 10.0.0.101
netmask 255.255.255.0

and on the other VM:

auto eth1
iface eth1 inet static
address 10.0.0.102
netmask 255.255.255.0

After a shutdown -r now or a ifup eth1, the two VMs could ping each other via their internal IPs 10.0.0.101 and 10.0.0.102.


  1. Add (create) a NAT Network within Virtual Box
  2. Connect each of the two VMs to that NAT network
  3. Make sure that each VM has a unique MAC address
  4. if you have statically assigned IP addresses, make sure each VM has a different IP address within the 10.0.2.0/24 ip range
  5. if you want to ping VM B from VM A via its host name, add the host name of VM B and the matching IP into your hosts file on VM a (and vice versa)