Monday, March 9, 2015

VM to VM communication in VirtualBox (Linux)

(amazing how many examples on youtube are done with Weirdos... few of them use Linux...)

The official documentation says: https://www.virtualbox.org/manual/ch06.html
"NAT: by default virtual machines cannot talk to each other"

Problem is that most of the time I start multiple VM on my host with the purpose of making them communicate with each other! So am I screwed?

An option which looks promising is Internal Networking : "Internal Networking is similar to bridged networking in that the VM can directly communicate with the outside world. However, the "outside world" is limited to other VMs on the same host which connect to the same internal network.". One could use also " bridged networking " but with Internal you don't need an adapter. One Internal Network is available: intnet. But there is a HUGE limitation: "As a security measure, the Linux implementation of internal networking only allows VMs running under the same user ID to establish an internal network." . Bummer.

Frankly "Host-only networking " seems the most promising. it was designed exactly to let multiple appliances cooperate.

I usually use Host-only networking and give "real" IPs to my machines and they see each other without problem.

With Vagrant you can just use something like this:

config.vm.network "private_network", ip: "192.168.58.101"

And you will be able to connect from host or from any other guest using 192.168.58.101 and the good thing is that IP will only be visible on your machine.



Read these great presentations:
https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
https://technology.amis.nl/2014/01/27/a-short-guide-to-networking-in-virtual-box-with-oracle-linux-inside/


No comments: