Connect VirtualBox VMs

Here is a way to set up networking in VirtualBox VMs so, that VMs can see each other and also the Internet.

For experiment I used VirtualBox 4.3 on Mac OS X 10.9.

Created two VMs with Ubuntu 14.04.

You will need two Network adapters – one for communication between VMs, and another for communication with the outer world. On both VMs set similar Network settings:

Adapter 1

Attached to : NAT

set1

You can also set Port Forwarding here to be able to access VM from the host. Here I’ve open port 22 for SSH access. I’ll be able to connect with “ssh -p 2200 user@localhost” from the host.

set2

Adapter 2

Attached to: Internal Network

Name: network-name

Name can be anything, but must be the same on both machines.

set3

Now start you VMs and open a Terminal window. Test with “ip addr s” command that you have these network interfaces: eth0 and eth1.

Assign a static IP to the interface of Adapter 2 (type “Internal network”). For me it is eth1. The other one should already have IP address, so you can tell which one you need by “ip addr s” command.

I used addresses 10.0.1.3 and 10.0.1.5. For subnet mask I used 255.255.255.0 (CIDR 24 ), which means that all addresses 10.0.1.X will belong to my virtual network.

Set IP address in terminal window:

and on the other machine:

Test that your first machine is visible from the second:

Leave a Reply

Your email address will not be published. Required fields are marked *