how to access samba on a guest Linux behind the VirtualBox NAT?

On my laptop, I'm running Ubuntu 9.10 under WinXP using VirtualBox 3.1.2. I want a setup where:

  1. The guest can freely access the internet.
  2. The host can access the guest files via Samba.
  3. The setup must work whether or not my ethernet/wifi ports are connected.

Is it possible?

#1 works with NAT and bridged networking.

#2 works with bridged and host-only networking.

Bridge-based setup doesn't work if relevant physical port is not connected. At the office, the laptop is connected to wifi or ethernet. At home, wifi only.

Is there a workaround? Am I missing anything? I hope I'm making my question clear.


Solution 1:

I would try setting up two separate network adapters.

  • Adapter #1 would be your current #1 setup: NAT to allow access to the internet available.
  • Adapter #2 would be a host-only setup to provide the connection between the host and the guest for the Samba shares.

Solution 2:

Another possibility is to create two bridged virtual NICs, one to the physical wireless interface and one to the physical wired interface. As long as one (or both) of the physical interfaces is connected you should have access. I generally try to avoid NATing as much as possible, since it tends to create a lot of headaches in the long run (as you have seen with file sharing).