Ubuntu – Samba: how can I access a share on a Virtualbox guest (in NAT mode)

12.10sambaserversshvirtualbox

My OS: Windows 8

Virtualbox guest: Ubuntu 12.10 server

I configured apache server on vbox guest and mapped http, https, ssh port successfully into ubuntu server. It works nice without any problem.

My network card is in NAT mode. After some research I installed samba on guest system.
I need to map /var/www/ folder on windows 8 so that I can work directly inside guest server from windows.

Here is my smb.conf

[share]
 comment = "Vbox server share"
 path = /
 writable = yes
 read only =no
 browseable = yes
 force directory mode = 777
 force create mode = 777
 force security mode = 777 
force directory security mode = 777
 hide dot files = no
 create mask = 0777
 directory mask = 0777
 valid users = @users, tural, root
 delete readonly = yes
 guest ok = yes
workgroup = WORKGROUP

I know that mapping works when networking is in bridged mode, but I don't want to make my vbox server visible to network.

Also I confgured windows hosts file and mapped port 80 with vbox nat so that, when I open some domain that redirected into localhost on windows, it gets data from virtualbox webserver. If do bridged, I will not be able to open guest webserver

Is there any other way to make drive mapping possible with NAT or something else?

Best Answer

Configure a second adapter as host only, set the second interface on the VM to static ip that does not interfere with your local network(s), e.g., set /etc/network/interfaces to:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The host network interface
#auto eth1
#iface eth1 inet dhcp
auto eth1
iface eth1 inet static
   address 192.168.36.2
   netmask 255.255.255.0
   network 192.168.36.0
   gateway 192.168.36.1
   dns-nameservers 192.168.36.1

Then go to its properties from windows networking and set a static ip that does not interfere with your local network(s), e.g.: enter image description here enter image description here enter image description here enter image description here enter image description here

Related Question