VitualBox is a cross-platform virtualization application very similar to VMware that runs on Windows, Mac, Linux or Solaris operating systems. VirtualBox provides a generic virtualization environment for x86 systems meaning it may run operating systems of any kind. Also, VirtualBox is usually faster and easier to use than Qemu, especially on Windows and Mac OS X. We recommend to read the manual for a complete understanding of VirtualBox and its features.
Creating Virtual Machines
First, make sure your have installed VirtualBox version >= 4.1, if not you can download it from the official website.
Then you can either create a new Virtual Machine using the Oracle VM VirtualBox Manager or download one of our appliance. The Linux Microcore 4.7.1 appliance has been imported for the following example.
Now you could create or import other Virtual Machines so you can get more than one VirtualBox guest in GNS3 but here we will create 2 linked clones instead. The concept of linked clone is quite simple, the new cloned VMs will be working with “linked” virtual hard disk and all new changes will be saved in a newly created disk, thus saving your disk space while all changes made in the clone VM will not affect the base VM.
To create a linked clone, right-click on your base VM, here Linux Microcore 4.7.1, and select the “Clone…” entry. Choose a name, reinitialize the MAC address of all network cards and finally the clone type. Repeat the process to create one more clone.
After completing the last configuration, you should see your 2 clones, named HostA and HostB in this example. You are ready to link your Virtual Machines in GNS3.
Using VirtualBox VMs in GNS3
Check that VirtualBox is functional in GNS3. Go to Preferences -> VirtualBox, check the path to vboxwrapper and click on the provided Test Settings button. You should see a message if everything goes well. You only need to do this the first time you setup VirtualBox support in GNS3.
Go to the VirtualBox Guest tab to add the VirtualBox VMs in GNS3. Choose an identifier name, a VM from the VM list (you may have to refresh the list using the provided button) and other options:
- Number of NICs is the number of network interface cards you will see inside your VM (e.g. ifconfig on Linux).
- Reserve first NIC for VirtualBox NAT to host OS is to you have your first network interface card (e.g. eth0 on Linux) configured with network address translation (NAT), allowing your VM to access your host network and Internet (if your host can access it of course).
- Enable console support to activate a serial console access to your VM. Please note that serial console support must also be configured on the operating system running in your VirtualBox guest for this feature to work. Here is a howto for Debian/Ubuntu Linux.
- Enable console server (for remote access) is to remotely access to your VM serial console. GNS3 creates a mini Telnet server that act as a proxy between the serial console and Telnet clients. This feature requires the Enable console support to be enabled.
- Start in headless mode (without GUI) will hide the VirtualBox graphical interface when the VM is started. This option is mostly useful if you have configured the previously described console support.
At this point, you should have added and configured your Virtual Machines in GNS3 Preferences. You can now add your VMs on the workspace, link them, start everything and console to all.
Once booted, configure valid IP addresses on both guest OS and ping between them. Here are the configuration used in this example:
tc@Linux:~$ sudo su tc@Linux:~# ifconfig eth0 10.1.1.1 netmask 255.0.0.0 tc@Linux:~# ping 10.2.2.2
tc@Linux:~$ sudo su tc@Linux:~# ifconfig eth0 10.2.2.2 netmask 255.0.0.0 tc@Linux:~# ping 10.1.1.1
Congratulations, you made your fist VirtualBox lab using GNS3!
Remote VirtualBox server
This is a more advanced topic that shows you how you can use a remote VirtualBox server. To do so, you first have to start vboxwrapper.exe or vboxwrapper.py (requires Python) on your server (VirtualBox must be installed too). By default vboxwrapper will listen for connections on port 11525, this can be changed using command line options (use vboxwrapper –help to display them all).
$ python vboxwrapper.py VirtualBox Wrapper (version 0.8.4-RC4) Copyright (c) 2007-2012 Jeremy Grossmann and Alexey Eromenko "Technologov" Using VirtualBox 4.2.14 r86644 VBoxWrapper TCP control server started (port 11525). Listening on all network interfaces
On your client, go to GNS3 Preferences, select Show VBoxWrapper Advanced Options, then disable the Enable VBox Manager one. Add an external VBoxwrapper which is the server IP address and port, 192.168.1.69:11525 in this example. Finally, hit the Test Settings button.
You should then see a similar message in vboxwrapper on your server if the connection has been successful.
Connection from ('192.168.1.69', 54906) [Errno 54] Connection reset by peer
Finally, as showed earlier in this tutorial, add your VirtualBox guests and start using them as you would normally do. Remember that your VMs will run on a remote server and there will be no VirtualBox GUI on your client. This means you should have a way to access them and the easiest is either to configure console support or have a remote desktop (RDP) connection to your server.