Ubuntu – Ubuntu Server VirtualBox host-only adapter confusion (windows 7 host)

virtualboxvirtualbox-networking

really hoping this is right place to ask this question seeing that my host is a Windows 7 machine. I have 3 Ubuntu Server 12.04 VMs set up through VirtualBox 4.1.18, and envisage the following usage:

  • LAMP – for Drupal, Moodle and other arbitrary PHP test applications (additionally a few of the Drupal installs need to communicate with some internet services)
  • SSH – to SFTP to the /var/www directory using FileZilla from Win7
  • SMTP service – for Drupal and Moodle installs to send test emails out from them.

Before I continue, I must stress that I'm not deeply knowledgeable with regard to networking in general, but I did read up on a few things to not make a complete fool of myself here!

I only have a single machine on my physical network – a laptop which connects to my router via WiFi and which picks up:

  • DHCP enabled = Yes
  • IPv4 = 192.168.1.6
  • Subnet Mask = 255.255.255.0
  • IPv4 Default Gateway = 192.168.1.254

And currently under NAT, VirtualBox assigns an IP of 10.0.2.15 to my VM.

I started reading the following article (Host-Only Networking With VirtualBox) which was exactly what I wanted to accomplish, and got a good idea of how to setup NAT and Host-Only adapters for each desired VM. However I then got confused when I read this article (Networking between host and guest VMs in VirtualBox).

VirtualBox > File > Preferences > Network > Edit Host-only adapter, shows me an IPv4 address of 192.168.56.1 and Mask of 255.255.255.0. Would the following configuration for /etc/network/interfaces be correct for static IP under the VM:

# The host-only network interface
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

I am confused about the second referenced article mentioning that NAT will give 10.0.2.15 on eth0, but then Host-only eth1 should be static and set to 10.1.2.1*. From the article: "Each NAT adapters and Host-only adapter should not reside in same sub-network". What should my eth1 interface block above contain? I am hesitant to try various options in case I end up breaking something, which why I'm asking here first…basically, What is the right way to this?

Thank you having the patience to read my question. Sincerely hope you can help me. TIA.

Best Answer

The host-only adapter allows the host and the VM to communicate with each other over the network. In other words, that is what is used when you SFTP to the /var/www directory. The host-only adapter in the VM must be on the same subnet as the virtual adapter on the host. On my system, it looks like this:

Host: 192.168.56.1

VM: 192.168.56.3

The NAT adapter in my VM has been assigned to 10.0.2.15, which doesn't match any of the adapters in the host.