This article will show you how to setup a complete virtual lab on a spare PC at home and allow you to access it remotely over the internet. Imagine having access to a complete test Windows domain environment, a linux server or workstation, a test bed for new operating system testing or even a clean and secure PC you can use for an type of testing that can be destroyed and rebuilt in seconds. All of this is possible and best of all you can do it with the latest technologies for free and manage the whole platform over the web.
There are a few things you will need to setup this environment:
- A spare PC with at least 4Gb of RAM and 100Gb of available storage (the more RAM and disk space the better)
- Oracle VirtualBox Personal Edition
- An always on internet connection
- Some time and patience
Step 1 – Build your PC
This is the easy part. If the PC came with a restore disk then you can use this to wipe it and set it back to its initial factory state. If you do choose this route then you will also want to go into Add/Remove Programs and uninstall any junk applications that came with the machine as this box will be acting as the host server. You will not actually connect to the server from remote locations.
If you don’t have a restore disk then you can rebuild the machine with a Windows Installation disk. This is cleaner and will give you the best server platform for your Virtual computing. I recommend you use a 64bit edition of Windows otherwise you will not have the maximum amount of RAM available for virtual machines.
Windows 7 64-bit is the best option.
Step 2 – Install VirtualBox
Oracle provide a free-for-personal-use edition of VirtualBox that is ideal for this project. This also comes with an extension pack that you can download separately. This gives access to USB redirect and some other nice features. Use the default installation options when installing.
Install the extension pack once the installation has completed.
Step 3 – Install phpVirtualBox
To do this you will need a webserver with PHP enabled. You could use IIS and do an install of PHP for this but that requires some technical knowledge. An easier solution is to install XAMPP on the machine and install Apache and MySQL as services. This will give you a full featured webserver with PHP preconfigured and ready to go! Once XAMPP is installed simply unzip the phpVirtualBox files into the htdocs root folder. The default locations for this is:
Now follow the instructions in the README file for phpVirtualBox (C:\xampp\htdocs\README.txt). Remember to change the default username and password!
You can now access the phpVirtualBox web interface by browsing to http://127.0.0.1/ on the host machine or by entering the correct IP address for the host machine in a browser from one of the other machines on your network.
Step 4 – Start Creating Virtual Machines
If you are feeling lazy you don’t even need to create your own virtual machines. You can download prebuilt VMs from these repositories:
Most Linux distros are available and pre-configured with the VirtualBox Guest Additions. If you need Windows machines then you will have to do an install from CD or ISO and you will also need a valid license key. These can be obtained through TechNet or MSDN. You can also purchase licenses directly from Microsoft.
Perform a normal installation of the Windows OS and don’t forget to install the guest additions.
Each Virtual Machine has an option to allow remote display. You MUST activate this. The setting can be found under:
Settings > Display > Remote Display
- Tick the box that says ‘Enable Server’
- Ensure the port is set to ‘3389’
Step 5 – Test your Virtual Machines
Make sure the Virtual Machine starts up correctly and that you can logon to it. Now from another machine run the Remote Desktop client. On Windows you can type mstsc.exe in the run box to start this application. In the Computer box type the name or IP address of the host machine that is running the Virtual Machines. The client should connect to the currently running Virtual Machine. If you are running more than one Virtual Machine then only the first machine is accessible. You will need to shut down all running machines and start up the machine you wish to connect to in order to change which machine is accessible since only one desktop can be made available over port 3389 at a time. I will write a post at a later time to allow access to multiple machines running on the same host.
Now that you can connect via the network to the running machine(s) lets make this all accessible via the internet:
Step 6 – Enable Internet Access
This will require you to configure some port forwarding on your router. There are 2 ports that we are interested in: Port 80 for the phpVirtualBox web interface and Port 3389 for the remote desktop.
The settings you require are:
|Protocol||Port Range||Translate To||Trigger Protocol||Trigger Port|
This configuration will pass the required ports from the internet to the host machine. You must remember to associate this port forwarding with the relevant host machine on your home network.
To access the phpVirtualBox web interface enter the IP Address of your external IP connection in a browser.
To access a running Virtual Machine enter the external IP address into the Remote Desktop client.
Step 7 – Making Life Easy
Most home users have a dynamic IP address which means their external IP address changes every few days. To get around this you can use a service such as DynDNS to automatically update a DNS record with your current IP address. This will allow you to use something like myhomevirtualdesktops.dyndns-home.com in the address bar and in the computer connection box to connect to your virtual platform.
Step 8 – Making Life Even Easier
Some organisations and ISPs block the DynDNS domains as a security measure. A simple solution is to use a CNAME record for your own domain. If you have your own domain name such as bobjones.com then you can ask your hosting provider to create a CNAME record for your domain such as homevdi and point it to your DynDNS record. So the chain looks like this:
homevdi.bobjones.com > myhomevirtualdesktops.dyndns-home.com> [Your current IP Address]
Now you can access your Virtual Machine lab from anywhere!