Configure VMs which talk to each other.

Hi,

This blog will walk you through setting up three different fedora VMs : ram, daisy and rincy; who will be talking to each other and also with the host machine; very soon…

Pre-requirements:

  • 3VMs already setup inVirtualBox.
    • See mine below. Name doesn’t matter much. You may use your own. My VMs run fedora OS. Depending on your OS, you may have to Google a little more on how to set different configurations. I am sure, Google will be happy to help you.

Screen Shot 2015-03-15 at 9.29.44 pm

 

A little help with my vocabulary:

host machine : machine which runs VirtualBox
VM           : Virtual Machine

First we need a Host-Only Adapter. This needs to be created in the Virtual Box and not in any particular VMs. So lets do that first.

Go to the preference of VirtualBox. Mine is a Mac. Don’t confuse with the screenshots if you are using another host OS.

Screen Shot 2015-03-15 at 8.49.51 pmGo to the “Network” tab and choose “Host-only Networks” sub-tab and create a new Adapter by clicking on the green plus sign you see on the right side of the window. There comes the new adapter “vboxnet0”

Screen Shot 2015-03-15 at 8.50.23 pm

Double-click “vboxnet0” or click on the screw-driver icon on the right side of the window after highlighting “vboxnet0”  to see it’s settings. Below are the default values and we are fine with it unless you really want to change it. You can see the “Lower Address Bound and “Upper Address Bound”. We can choose IP from this range for our machines.

Screen Shot 2015-03-15 at 8.51.04 pm

Press “OK” if you made some change else “OK” or “Cancel” as you like and we have a working “Host-only Adapter” now.

Now we should connect it to all three VMs.

Highlight a VM and click “Settings” (on the top of the window between “New” and “Show”)

Screen Shot 2015-03-15 at 8.51.41 pm

Select the “Network” tab from the window which appeared. Leave “Adapter 1” as we need it to be Attached to “NAT” for accessing internet via host machine. Select “Adapter 2” and select “Host-only Adapter” option from the drop down menu of “Attached to:”. Ofcourse the value for “Name:” is our newly created “vboxnet0”.

Screen Shot 2015-03-15 at 8.52.14 pm

Set “Promiscuous Mode:” to “Allow All” or “Allow VMs”. Putting it to “Deny” will stop any communication via this Adapter. Hope you too don’t want that as our intention is otherwise.

Screen Shot 2015-03-15 at 8.52.39 pm

Now we need to boot into the VMs and assign a static-IP for each.

I will start will “ram” VM.

In RedHat/Fedora we can use “system-config-network” for this purpose.

Install it using the below command. You should have root privilege or sudo privilege for this.Screen Shot 2015-03-15 at 9.18.47 pmOnce installed, run “system-config-network” command to start assigning the static IP.

Screen Shot 2015-03-15 at 9.19.24 pmThat will take you to something like this:

Screen Shot 2015-03-15 at 9.19.34 pm

Highlight “Device Configuration” from it using arrow keys and press “Enter/Return” key.

Screen Shot 2015-03-15 at 9.19.53 pmWe need to edit “vboxnet0”, so highlight it. If you don’t see that, you may highlight “” and press Enter.

Make sure your settings match the below ones. You may choose any IP from the range we saw earlier. I go for 192.168.56.[101-103]. Need not be adjacent ones.

Use tab and arrow keys to highlight the “OK” button and press Enter after the changes.

Screen Shot 2015-03-15 at 9.20.03 pmClick “Save”.

Screen Shot 2015-03-15 at 9.20.26 pm

Then “Save&Quit”

Screen Shot 2015-03-15 at 9.20.37 pm

With this, we have assigned static-IP 192.168.56.101 to VM: ram.

Now lets do a small trick to ease our path ahead; a small DNS resolution.

Lets use the names ram, daisy and rincy instead of the IPs.

For that, open the /etc/hosts file.

Screen Shot 2015-03-15 at 9.21.30 pmAnd add below lines to it.Screen Shot 2015-03-15 at 9.21.51 pm

Like wise, assign 192.168.56.102 to daisy and 192.168.56.103 to rincy and update the /etc/hosts file.

Now reboot all the VMs to be on the safer side. and try the below commands in all three VMs and host machine.

ping -c 3 ram
ping -c 3 daisy
ping -c 3 rincy

You will get the below output which means rincy, ram and daisy started talking to each other..

Screen Shot 2015-03-15 at 9.23.12 pmTry from the host machine and you will see Big-Daddy can talk to his children now..

Screen Shot 2015-03-15 at 9.24.52 pmSo there comes an end to this blog..