Wednesday, February 05, 2014

Using NAT, and Host-Only Adapter for Virtualbox

A virtual machine using a bridged-adapter as its network adapter will have its own unique IP address. In small networks, as much as possible, IP assignment should be limited. This is where Network Address Translation (NAT) comes in. The VM client will still have connection to the Internet, or within the host's network while also not getting assigned its own IP. Any traffic by the VM client is seen as traffic from the VM Host.

In my old post, I used samba share if Windows is used to run virtualbox. And then, any editor can be used to edit the rails files. My dilemma was using samba share in my Xubuntu machine while maintaining the NAT network set on my machine. I tried port forwarding to address ssh, and accessing rails via the browser. But I couldn't seem to solve the samba port forwarding. Instead of figuring out the exact ports to forward for samba, I just used the Host-Only Adapter for virtualbox.

If you are using Windows machine, this is readily available. For Xubuntu, or any other linux-based OS, this should be created first in Virtualbox. To do this, open Virtualbox preferences or press CTRL+G. Then, select the Network. You should be seeing something similar to this:


As you can see, I already have my host-only network in the image above. If this is the first time you are doing this, yours should be empty. Next, you may add a network by clicking the add button. (The green one with the plus sign)

From here, a default set of IP address will be generated by Virtualbox. You may change this if you want to suit your needs. Afterwards, if your OS in your client is already installed, you may need to edit your settings so that your guest OS can use your new adapter. In my case, I already have Ubuntu Server 12.04.3 LTS installed already, thus, I added the following to the file interfaces located at /etc/network/interfaces

auto eth1
iface eth1 inet dhcp

I restarted the networking service after. If you want to set a static IP, you may do so.

No comments:

Post a Comment