May 17, 2009

VirtualBox: Accessing GuestOS services

Posted in Tips tagged , at 7:56 pm by Karel MALBROUKOU

Some of you already thought about how to access easily your VirtualBox‘s GuestOSes from your Host OS or from the network, like me, I am sure of it.

Don’t worry, here’s I’ll give you a way of doing it!

First, find out where are your Guest machines configuration. By default, it should be in your HOME directory, in ~/.VirtualBox/Machines/.
Here you will find your different machines, and inside of each folder, you will find a XML file.

You could use two ways to do it, either you edit the XML file, or you use the VirtualBox manager (command-line).

For this tip, we will take the example of accessing the GuestOS web server (port 80), from the port 8888 of the Host OS.

Edit the XML file
Go inside the folder of the machine that you want to have network access to.
For example: cd ~/.VirtualBox/Machines/Gentoo/
Inside you will find the XML Gentoo.xml
Edit if with your favorite editor and inside the section <extradata>, add the following three lines:
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/>

Using VirtualBox Manager
You need here to use the VBoxManage command as followed:
$ VBoxManage setextradata Gentoo "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" 8888
$ VBoxManage setextradata Gentoo "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" 80
$ VBoxManage setextradata Gentoo "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" TCP

This command allows you to manage the whole VirtualBox application settings via the command line, it’s up to you to find out the other options.

Play with it!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: