SSH from one Virtual Machine to another in VirtualBox

Solution 1:

You want to set up either an internal network or a host-only network. The practical difference between the two is that the host computer can participate in a host-only network, but not an internal network.

Assuming you want to use an internal network, the basic process is as follows:

  1. On each of the guest VMs, set its network adapter to "internal network" OR add an additional network adapter and set it to "internal network". Make sure that the network name is the same for each guest.

  2. Set up a DHCP server for the internal network, as described here.

  3. When you start the guest VMs, they'll see an additional network adapter. Most modern operating systems will configure the network interface from the DHCP server without any fuss.

If you use a host-only network, the process is as follows:

  1. From the Virtualbox VM manager, select File->Preferences->Network and set up a host-only adapter. You can set up a DHCP server from the GUI here. When you complete this process, you'll see a new virtual interface appear on the host. That is how you will communicate between the host and guests.

  2. On each guest, change its network adapter to use the host-only network, or add a new network adapter set to the host-only network.

  3. Start each guest. They should get an IP address from the DHCP server.

Solution 2:

I usually setup bridged network for all my VMs, so I can access my VMs from anywhere on my network.

If you want make VM to VM communications faster, use host-only networking. For host-only networking, you have to enable it and create either a DHCP server (within options of virtualbox) or use static ip-addresses on you VMs.

I have DHCP on my router and I have an internal DHCP server for virtualbox. So if I have VMs with more than 1 internet/ethernet requirement, I create 1 bridged and 1 host-only network.

I also make sure "allow all" is enabled under the network card.