Sunday, July 20, 2008

VirtualBox NAT Configuration

Sometimes it might be useful to be able to open network connections from the host machine to the guest machine. For instance the guest machine may be running a web server and it could be needed to connect to it from the host computer.

In Virtualbox, network connectivity to the guest system is usually provided by NAT. However Virtualbox NAT connectivity provides a way for the guest system to access outside network, but not a way the outside network, or even the host machine to connect to the guest.

The solution here is to use “Host Interface”. Virtualbox Host Interface is something like a “fake” network interface connecting host system and guest system. Both the operating systems see the interface as a real network interface they can use to communicate.

The setup I am describing here consists of Windows XP as Host and Gentoo Linux as Guest systems

Configure virtual machine networking

  1. Go to the network setup panel in the virtual machine configuration tool
  2. Add a new Host Interface. Just click the small icon with a “plus” near the host interfaces list. Just give a name to the interface (in the example: VirtualBoxHost 1). While the operation of adding the new interface is in progress, the actual driver of the interface will be installed, and windows will warn you about the fact that the driver itself is not certified bi Microsoft: continue anyway.
  3. Then select “Host Interface” in the “Attached To” combo box
  4. Finally select the newly created interface in the “Interface Name” combo box

Configure TCP/IP for the Virtualbox Host Interface

Before starting the virtual machine, the new interface should be configured in the Host system, just as any other network interface, assigning at least an IP address, a network mask and a default gateway. For instance: IP=10.0.0.1; Mask: 255.255.255.0; Gateway:10.0.0.1.

Configure TCP/IP for the Virtualbox Guest Interface

Now the guest system could be started. Once it is started, its network interface should be configured. In this case just disable DHCP and manually enter network configuration. For instance: IP: 10.0.0.2; Mask 255.255.255.0; Gateway: 10.0.0.1

Now the configuration is complete and you are able to open network connections freelyy between the two systems.

No comments: