2008-08-14

A much easier way to access Samba share on Linux guest on Windows host

There is a much simpler solution to my earlier's one.

Steps:

  1. Create a VirtualBox's HIF and attach it to the VM.
  2. Set its IP address to, say, 192.168.2.1.
  3. Start the guest OS.
  4. From within the guest OS, give a static address to the HIF, say, 192.168.2.2.
  5. From host OS, make sure you can ping 192.168.2.2
  6. From the guest OS, make sure you can ping 192.168.2.1

This establishes a private network between the host and the guest. The guest is perceived as another node in the network hosting a Samba share.

VirtualBox: Accessing Samba share on Linux guest on Windows host

Environment: VirtualBox 1.6.4 (latest as of 2008-08-14) running on Windows XP SP3. Guest is a Debian GNU/Linux.

The goal is to have the host Windows able to mount a Samba share provided by the guest as long as the Samba instance is running. To accomplish that, we are going to create a loopback adapter interface on the host, use VirtualBox's HIF on the guest, and bridge the two interfaces together.

Steps:

  1. Add a Microsoft Loopback Adapter device (through ControlPanel->Add Hardware).
  2. Create a VirtualBox's HIF and attach it to the VM.
  3. Go to Control Panel->Network Connections.
  4. Highlight the loopback device and the HIF, and right-click 'Create Bridge'.
  5. Go to the newly created bridge's property and set its IP address to, say, 192.168.2.1. The guest OS will be able to contact the host OS with this address.
  6. Start the guest OS.
  7. From within the guest OS, give a static address to the HIF, say, 192.168.2.2.
  8. From host OS, make sure you can ping 192.168.2.2
  9. From the guest OS, make sure you can ping 192.168.2.1
At this point, from the host Windows, you should be able to do this:

net use e: \\192.168.2.2\the_share_name "password_for_share" /user:username_for_share /persistent:no


Update 2008-08-14: You don't have to create a bridge. There's a simpler method.