PCs

Using VirtualBox VMs on your network's subnet

If you drop down from the clouds you will see there are actual virtualization solutions that can be had on the cheap. Jack Wallen demos one here.

Virtualization is HUGE now. Companies are virtualizing nearly everything. Here's the problem -virtualization products can be quite expensive. So much so, most small shops can't afford to make use of this amazing tool. But if you drop down from the clouds you will see there are actual virtualization solutions that can be had on the cheap. In fact, there are virtualization solutions that can be had for free (unless you are going to virtualize a proprietary OS like Windows).

One of those solutions is VirtualBox. VirtualBox is an x86 x86_64 virtualization product that is as useful to the enterprise as it is for the home. But not all is obvious for those enterprise users trying to make virtual machines, served up by VirtualBox, work within their network. A big issue you will come across is making your virtual machines (regardless of platform) play well on your network's subnet. Although you might think the configuration options to handle this would lie within the guest OS, it actually must be configured within the host. So let's take a look at how this is taken care of.

NOTE: For this article I will be using VirtualBox OSE on a Ubuntu 10.10 host and a Windows XP guest.

Step 1: Start up VirtualBox.

I do, of course, assume you already have VirtualBox installed as the host as well as a working guest OS  installed. That being the case, start up VirtualBox.

Step 2: Stop the virtual machine to be configured.

This is a must, as you cannot open up the settings window if the virtual machine is either paused or running. The virtual machine must be stopped. If the virtual machine is on pause, fire it up, and then completely shut down the virtual machine operating system.

Step 3: Open the Settings window of the guest OS.

Once you have the guest OS shut down, select the Guest OS entry in the main window, and click the Settings button. When the Settings window opens click on the Network tab to make the necessary changes.

Step 4: Configure the bridged network.

In order for your Guest OS to live on the same network as your host OS, the Guest OS networking configuration must be in Bridged mode. Figure A shows how this is configured.

Figure A

guest_settings.png

This particular host/guest resides on my laptop, hence the wlan0 (Wireless) network adapter name.

Where this can be tricky is the Adapter Type settings. To get to this setting you must expand the Advanced section. In this advanced section you can configure:

  • Adapter type
  • Mac address
  • Cable connected

The more important of the three is the Adapter type. VirtualBox can virtualize the following six types of network adapters:

  • AMD PCNet PCI II (Am79C970A);
  • AMD PCNet FAST III (Am79C973, the default);
  • Intel PRO/1000 MT Desktop (82540OEM);
  • Intel PRO/1000 T Server (82543GC);
  • Intel PRO/1000 MT Server (82545EM);
  • Paravirtualized network adapter (virtio-net).

The default is PCNet FAST III because it is supported by nearly every operating system out of the box. If, after setting up your bridged network, your network does not respond, this setting is what you will most likely have to change. Although it's a hassle, if your bridged network doesn't work, simply shut down the virtual machine and repeat the process (selecting a different Adapter type) until it works.

OK your changes and fire up your Guest OS again.

Step 5: Configure your Guest OS network

More than likely your Guest OS is using DHCP. When you fire that Guest up it will now pick up a network address that belongs to the same subnet as your Host OS. Figure B shows my Guest OS reporting the same IP address scheme that my Host OS is on.

Figure B

guest_ip_info.png

Same IP scheme, same subnet, same gateway.

Now your machines on your network can see your Virtualized Machine.

Final thoughts

I get this question a lot. Usually it comes after the sender has pulled out their hair trying to see their virtual machines on their network. Well, now you can see just how simple it is to get that virtual machine on the same subnet as your regular network.

VirtualBox is an outstanding way to get virtualization taken care of without having to break the budget. It doesn't have the power that some VMWare tools have, but it will get you virtualized on a tight budget.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

14 comments
kimalasi
kimalasi

Thanks a lot for your help in this issue. I have the inverse situation where I have a Toshiba Intel i3 with 8 MB Ram 64 bit with Windows 7 Professional. I installed virtualbox 64 bits and create a hard drive of 8 GB and installed the guest system kubuntu 11.04. My headache was to see that the linux system when I use the ifconfig command it says that the ip is 10.0.2.15 and my network is a class C network 192.168.247.* . I tried manually to configure static ip address with the correct gateway and the correct dns servers but when i tried to ping an internet name like yahoo.com it says unknown host. So there was no internet or network connection. I follow your instructions and it works I just paused my virtual linux and make the changes in the settings in virtualbox and change the adapter from NAT to Bridge Adapter and in the advance area I put it in promiscous mode, Then I start again the virtual machine I turn off and on again the ethernet card in the kubuntu guest OS. It took the right ip address with the same subnet of all my systems in the network. Thanks a lot for your great advices.

Alpha_Dog
Alpha_Dog

If you have data and processes which need to be secured, a Virtual Machine can be created for this task. The VM can be placed off line during times it's not needed, brought online on verified demand only (our model), or even placed on removable media.

thecornerhouse
thecornerhouse

Does that mean that I can set my host up to use the networked printer, just as usual? I tried setting up printing through A VPN between host and guest using a (additional) bridged network adapter, but that made VB refuse to boot the guest.

chrisbedford
chrisbedford

Your host machine must have Lots of Memory. I capitalised that on purpose, just "lots of memory" isn't enough. And even so... maybe it's not just memory, I think you have to have a pretty powerful machine too. OK I'm basing that on a single example, and one running on a Windows host at that, but... I have an HP nx5000 notebook whose screen is beyond economic repair, but it's a perfectly working computer so I wasn't prepared to trash it. It's running XP with VBox and *nothing else*, and although the guest OS (ClearOS gateway, a Debian-based router package) tells me it is 96% idle, Windows tells me VB is using 86% of the computer's CPU. If I shut down the guest, that drops to nothing. Makes no difference if I allocate 630 MB to the virtual machine of the host's total 2 GB, or 1.25 GB (VB doesn't like it if you go over half the available) - the host machine is still running close to the red line all the time, and *very* slow to respond to its console. [b]VERY[/b] slow - often more than 5 seconds will elapse between input & response. Can be quite frustrating. The guest package runs fine, however. Obviously all the penalty or overhead is in the host. Wish I could run the guest OS on the native metal for comparison, but Clear doesn't support PC-Card (PCMCIA) and it's not worth the effort to find drivers and try to get them working. That is one HUGE advantage of virtualisation - with anything slightly non-standard, as long as your host OS supports it you can use it in the guest.

davidmurree
davidmurree

i always like to read some good and informative blogs and this blog is also so good and helpful. thanks for taking time to discus this topic.. classifieds for rent

Neon Samurai
Neon Samurai

VMware Server's two great features for me where bridged networking as a pull-down option and guest boot at host bootup as a checkbox. When it first became unusable (with Debian), I looked at Vbox for about a week but never could get a bridged device setup for Vbox to use; for lack of a sane "bridged networking" pull-down option (Deb 5 Stable). The moment that option apeared (Deb 6 Testing), I reinstalled with Testing and never looked back. The only thing I miss now is the guest boot at host bootup. I could write a sudo script for this but it's been as easy to manually start my always-on VM; "vboxheadless -s groupware && startx".. nice and easy since that particular machine sits logged at GUI most of the time. The latest feature I've gotten into is folder sharing. I have some tools and my work files under the host OS. I have other tools in a VM for lack of a native alternative. Both host and guest OS seamless with the same working files. It might make a quick howto to like this one and provides a fantastic option for those accessing flashdrives for lack of USB bus support in the non-commercial version (OSE).

seanferd
seanferd

I finally realized that shutting down the guest might be a good idea. Cat is out of the bag, now!

pfyearwood
pfyearwood

I use nearly the same setup you used in your tutorial. That is, Windows XP Guest on an Ubuntu 10.04 LTS host. I use Virtual Box from Oracle. I found the first option, the PCNet PCI II worked. Since I assembled my own, I then tried the Intel MT Desktop option. If I may make a comment. If you use any option besides the first, you will need to have the drivers for a Windows XP Guest OS. Other than that, you solved a problem I did not know I had. I use Virtual Box as a test bed for Linux distro testing before I install on bare metal. I am self-taught on computers. It is so much easier to remove a VM that is not what I want to use than if I go straight to installation. Paul

Brian J. Bartlett
Brian J. Bartlett

Any application that sees occasional use and, in a few cases, must be handled securely is a prime candidate. The first one that immediately came to my mind in the early days of virtualization (2003) is my certificate authority. Keep it in an encrypted container (even keep it zipped up as well to save space) and only break it out when you need to generate a new certificate.

grassiap
grassiap

as DYI er myself I much much prefer to stick with the NAT or sometimes even host only networking and forward ports as needed. It involves some overhead but I find that much much safer than having an additional adapter that needs to be secured on both the host and guest. Besides (and I encountered the situation on my own laptop) NAT networking adapts better to changing the active host network adapter between sessions (i.e. wireless vs wired)

pgit
pgit

There is the "guest additions" package that allows for a shared guest/host folder. But I find it more productive to use samba/windows file sharing across the board. The guest/host add-ons are exclusive to the two. If there are any additional remote resources needed it's no different than an entirely physical network.

Neon Samurai
Neon Samurai

My VMs get the same lockdown that any of my physical boxes would get so opening a second network interface isn't an issue. I guess the risk would be a vuln in the actual virtual NIC driver which I'd expect a prompt vbox patch for. (be sure to get your v4.0.4 latest Windows build if you haven't yet) I guess I could NAT or host-only the liveCD testing VM but pretty much anything less ad-hoc then that needs to appear as a separate entity on my network. Pentargets, server development builds. Not that my needs are representative of everyone but NAT wouldn't cover them. If all one needs is host-only or connections out to the network then it is better to keep things contained though. Like my Samba/foldersharing comment above; I wouldn't want to open up attack surface or involve additional hardware/people if not actually required. Deny all and allow only as required.

Neon Samurai
Neon Samurai

Yup. the folder sharing enabled through guest addons. I didn't want to start opening shares on my notebook just to mount the flashdrive. With folder sharing, one gets the same affect as a mounted network share without opening your host up further (if you've not yet had reason for samba shares); no login credentials sprayed across the network, no opportunity to MITM the traffic, no involving unnecessary components, no modifying firewall rules. If my host OS was a Windows box though, I may have gone with a samba share instead. With both OS, it would mean modifying firewall rules though. No thinking about it, the firewall rules could be a pain; I either open them up wider than wanted to accomodate guests on dynamic IP ranges or I deal with guests on static IP which change depending on what network I'm under. Folder sharing takes that whole issue out of the picture since it's working inside the VM environment rather than looping through an external variable medium. Whichever works though; I'm happy to have both options available.

Editor's Picks