Whenever I have to setup a virtual machine on VirtualBox that has a web service running, I start scratching my head. 😅 Especially if I need to connect to it from the host, let alone other virtual machines. And frankly, I am so done with googling it up every time. So now, to remind my future self and to tell you how it’s done, I will walk us through it. 😃
First you need to go to VirtualBox’ own settings from File -> Preferences… and go to the following view.
So, under Network -> Nat Networks you have to click on the small add button to create a new network. This is the one all your virtual machines will be connected to.
Next, you need you to go to the virtual machine specific settings by selecting the desired virtual machine and clicking on the settings button.
Under Network -> Adapter 1 you will have to set the attached network to NAT Network and pick the network you just created in the dropdown menu below. Next you need to adjust the promiscuous mode to suit your needs either by allowing communication between virtual machines or letting the virtual machine access the whole network.
And there you have it. Now you can access your virtual machines from each other and the host machine by their respective IPs. As easy as that. Remember to bookmark this page so that you don’t end up googling how to do this again within a year when you have already forgotten about it. 😄