Networking with VirtualBox
Network in a Box
Tour the VirtualBox virtualization tool, a free and easy environment for virtual versions of Linux, Unix, and Windows.
VirtualBox is gaining popularity as a simple and effective virtualization alternative. This smart solution fits smoothly onto an ordinary Linux desktop, supporting a variety of Windows, Linux, and Unix guest systems. The German company Innotek [1] produces VirtualBox, which comes in both commercial and open source (GPL) versions.
On February 12, 2008, Sun Microsystems announced an agreement to purchase Innotek, with the goal of integrating the VirtualBox environment with Sun's own development tools. The long-term implications of this agreement are not yet known, but as of this writing, it appears that Sun plans to continue to support and maintain both the open and closed versions of VirtualBox. In this article, I will describe how to get started with VirtualBox virtualization.
Open Source or Commercial?
The commercial and open source versions of VirtualBox differ with respect to USB device support and remote desktop functionality, which Innotek restricts to the closed source variant. Both versions support several operating systems – such as Linux, OS/2, and Windows/DOS – and both have a graphical administrative interface.
From an installation perspective, the open source version on Linux is a little clumsy (see the "Installing the Open Source Variant" box). Packages from distribution-specific repositories are better integrated.
Your choice of distribution is likely to offer you a version of VirtualBox via the package management system. If you have enabled the correct installation sources, you can simply type apt-get install virtualbox on Ubuntu or zypper in virtualbox on SUSE to install.
Clicking the icon or typing the VirtualBox command launches the GUI. The New icon lets you create a new virtual machine, with a wizard helping you through the setup phase.
Instead of a genuine partition, VirtualBox uses a file with a disk image. Opting for dynamic as the image size makes sense; remember, the image will grow as you add content. Once the emulation is running, the window will completely capture the mouse pointer; the right Ctrl key acts as a host key and releases the mouse.
VirtualBox comprises two components: the VBoxSVC XPCOM daemon and the Virtualbox front end. Of course, the daemon must be running before you launch the GUI, but there is no need to install separately. The steps outlined here will launch VirtualBox directly from a local folder.
Installing the Open Source Variant
To build the source code, you will need the following tools and libraries, plus the developer packages:
- GCC
- Assembler as86 (typically included with the dev86 or bin86 package)
- Bruce Evans' Compiler BCC (typically included with the dev86 package)
- Intel's ACPI Compiler IASL (this is in pmtools on openSUSE)
- libxslt
- libxerces
- libxalan
- QT version 3.3.5 or newer
- libidl
- SDL, Alsa, and HAL, as provided by libhal
After resolving the dependencies, you can enter wget http://www.virtualbox.org/download/1.5.2/VirtualBox-1.5.2_OSE.tar.bz2 to download the source code archive [2].
After unpacking the archive, type the following commands in the VirtualBox source code directory to configure:
./configure source ./env.sh kmk all
This installs VirtualBox and its collection of tools in the out/linux.x86/release/bin/ subdirectory. Before you can launch the box, the system requires the matching kernel module:
cd out/linux.x86/release/bin/src make sudo make install
Of course, you need the kernel sources for this build step. Working as root, you can enable the kernel module by entering modprobe vboxdrv before going on to allow non-privileged users to access the new device file: chmod 666 /dev/vboxdrv. Now you can launch VirtualBox:
LD_LIBRARY_PATH=. ./VBoxSVC& LD_LIBRARY_PATH=. ./Virtualbox
Connect Four
After completing the installation, the next step is to select – in the GUI – the virtual machine whose network settings you would like to configure and Machine | Change in the menu. Then select the Network entry on the left to access the settings (Figure 1).
Up to four virtual network cards are available for each machine, Adapter 0 through Adapter 3. By default, only one NIC is configured for each machine; you need to click the corresponding tabs for the other NICs.
The Network cable attached switch allows the administrator to flip the virtual network switch. The card stays in the virtual machine; however, the connection to the outside world is interrupted, just as if somebody had unplugged the network cable. This control is good for tests or for re-initializing hotplug-capable guests.
Each of the four network cards can run in one of three possible operating modes as specified in the Connected to drop-down menu. This specifies who the virtual network card will talk to and to which other computers it is visible. The options are:
- Internal network
- Network Address Translation (NAT)
- Host interface mode
Internal Network
VirtualBox can simulate a separate internal LAN for the virtual network cards, with any number of virtual machines on the virtual network that will not see or talk to anybody else, including the host and computers outside of the internal network where your guest systems reside (Figure 2).
At first glance, the internal network doesn't seem particularly useful, but there are several good reasons for using it. Because the virtual LAN is completely isolated, no external influences can affect it, which makes the internal LAN a perfect choice as a test or troubleshooting environment.
In the other two modes, any data transmitted is also sent to the host system's network interface. If two virtual machines need to exchange data, this approach nearly always affects speed or presents a security problem. To connect a virtual network card to the internal LAN, select Internal network below Connected to in the GUI.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4
-
Fedora Unleashes Atomic Desktops
Fedora has combined its solid distribution with rpm-ostree system to make it possible to deliver a new family of Fedora spins, called Fedora Atomic Desktops.
-
Bootloader Vulnerability Affects Nearly All Linux Distributions
The developers of shim have released a version to fix numerous security flaws, including one that could enable remote control execution of malicious code under certain circumstances.