I believe that all development should be done on virtual machines because of the ability to backup and restore them as simple files. I use my Microsoft Surface Pro 4 as the host and and have two guests; a Windows 10 development box with IntelliJ and PuTTY on it and a Bitnami WordPress appliance that is based on Ubuntu.
This works well but I quickly got tired of playing “guess the IP” every time I changed networks and the virtual boxes got a new IP from DCHP. The whole point of having a laptop is that you change networks!
This article will tell you how to add as static IP to your virtual boxen.
Step 1. Create Host Adapters
Open Virtual Box manager and go to Preferences. Create a Host Adapter (or two if you have two virtual machines like I do). Configure them to be on 192.168.56.1 and .2 (I think you could chose any network but this seems to be a common choice.)
Step 2. Add Host Adapters to virtual machines
The next step is to add the host adapters to your host machines. Go to the setting for each machine and chose a host adapter and make it the first adapter on the machine. It is important that you make it the first adapter because the Bitnami applications will bind to this and you want them on the fixed IP.
Step 3. Configure the network adapter in the guest OS
We have added the “physical” card to the computer. Now we have to configure them.
On a Windows computer this is very easy. Control Panel > Network and Sharing > Change Adapter Settings > (Choose Adapter) > Properties > TCP/IP and add an IP. I used 192.168.56.102. You should now be able to ping this IP from the laptop.
On a Linux computer such as Bitnami WordPress Ubuntu appliance this is more difficult because there is no GUI. I have no desire to relearn Linux so I simply installed Webmin. I can then use the Webmin to configure a new network interface on 192.168.56.100. Unlike Windows 10 Webmin does not report hardware you have to enter “eth1” as the name of the interface. This is because Linux will create this “physical” adapter when you add it in Virtual Box.
You may need to reboot. You will now be able to ping it from the laptop and because both virtual machines are on the .56 network they will be able to see each other. I can set up WinSVC and PuTTY and IntelliJ on my development machine confident that the the IP address of the WordPress machine will not change.
Step 4: Add adapters to connect the virtual machines to the internet
After the previous step the laptop can see each virtual machine and they can see each other but not the Internet (the clue is in the name “Host Only” adapter). Since you will want to connect to the Internet for Windows Updates and Linux updates (apt-get) you need to install additional adapters.
Go back into Virtual Box and in each virtual machine add a “Bridged” adapter as the second interface. This adapter will pick up its setting by DHCP whenever you change network. It is possible that can skip this step because you already had bridged adapters in place and simply moved them in earlier steps.
I got many of the ideas for this article from Jobacle and it is not as precise as I would like because as is often the case I am writing it as a nice process that I would have followed if I not tried lots of other sequences first.
If you would like to provide feedback or comments please do so below.