Ubuntu Server VirtualBox host-only adapter confusion (windows 7 host)
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.
Related videos on Youtube
maGz
Updated on September 18, 2022Comments
-
maGz over 1 year
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 of255.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 to10.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.
-
maGz almost 12 yearsThank you! I bit the bullet and set up a new Ubuntu VM with NAT as Adapter 1, and then after installation was completed I shut the Vm down, enabled Network Adapter 2 as Host-only and restarted the VM. Edited the
interfaces
file as per my original post, rebooted the VM and anifconfig
showed that the change was registered. I can ping from the VM and download packages, and I can SFTP and SSH to it, and browse to LAMP apps from host browser. Thank you for confirming these for me. -
maGz almost 12 yearsin the interfaces file, what is
broadcast
? Is this similar to nameserver? -
Tom almost 12 yearsThe braodcast ip is usually your network with 255 for the last octet: ip 192.168.0.1, netmask 255.255.255.0, network 192.168.0.0, broadcast 192.168.0.255. The broadcast address is used to send a message to all the computers connected to a LAN (by sending ONE message to the broadcast address.)