2 VM's talking to each other

Updated on 11 Oct 2021

Create your network

In order for VM’s to communicate with each other, they need to be connected on the same network. We can do that in VirtualBox in the following way (make sure you are not running any of your VM’s when you perform these steps).

Choose File | Preferences | Network.

Click the + button on the right to add a new Nat network.

I’ll just keep the default settings and rename the network to BrentNatNetwork.

Attach your VM to the network

Now that I have created the BrentNatNetwork, I need to attach my VM’s to this network.

Click on the VM and choose Settings | Network. From the drop down select Nat Network.

Make sure in the other drop down BrentNatNetwork (or whatever you named your network) has been selected.

Ping test

On the server I run ifconfig and see that I have an internal address of

From my Ubuntu desktop I can now ping the server.


Apache test

For this test I will install lamp-stack on the Ubuntu server and allow http thru the UFW.

sudo apt-get install tasksel
sudo tasksel install lamp-server

sudo ufw allow http

Now I will try to navigate to the ip address in the web browser from my desktop.

Hosts test

I really like the fact that I can network my VM’s, ping them and open a website on the server from my desktop (even if it is the Apache test page). What I would like to do now is have the ability to navigate to that website with the following address: http://server1.

Modify /etc/hosts file and add this line (making sure to modify the IP address for your setup).    server1

Now I can navigate to the website that is served up by the server by using the http://server1 url.