I have created a VirtualBox VM, which is running Debian 9 as the guest OS, and it can connect to the internet successfully using the default NAT network interface.
We also need the web server and ssh server in the VM to be accessible from the host computer OS (Windows 10, if relevant), but not from the internet at large. When another colleague asked me to set up a similar VM some time ago (but with Debian 8 and Windows 7, respectively), after much experimentation, it seemed that creating an additional Host-only Adapter in the guest OS, and updating the
hosts file on the host OS to map the hostname set up in the VM guest OS to its (private) IP address "just worked".
However, I don't seem to be having similar success with Debian 9, perhaps because the way that networking is now set up seems to have changed?
The NAT interface appears as
enp0s3 with private IP 10.0.2.15, and it can connect to the internet, but a web browser or ssh on the host OS cannot see this address.
If I shutdown the VM and add an additional Host-only network adapter, when I reboot the VM, I now have an additional interface called
enp0s8, but it is "down" and does not have an IP address associated with it.
Do I need to do something else to set up this interface, or is VirtualBox supposed to take care of it?