Pages

Wednesday, April 16, 2008

VirtualBox NAT folder share in Linux

Oops. I forgot the Linux part of this post.

In my Linux guest OS (Fedora 8), I changed two files to get NAT file sharing to work.

Added host computer name to /etc/hosts:

10.0.2.2 czflmc1

Added folder shares to /etc/fstab to auto-mount:

//czflmc1/C$ /mnt/C cifs auto,rw,user=dude,pass=x,uid=500,gid=500 0 0
//czflmc1/D$ /mnt/D cifs auto,rw,user=dude,pass=x,uid=500,gid=500 0 0

Works like a charm! YMMV... (Your Mileage May Vary)

P.S. I had to create the /mnt/C and /mnt/D directories as root first.

VirtualBox NAT folder share

Interesting tidbit about VirtualBox NAT (Network Address Translation) file sharing. NAT networking is exceptionally convenient because it doesn't modify your host networking settings but shares it with the guest OS. I was trying to figure out how to share SMB/CIFS folders from my host OS (Vista SP1) to the guest OS (Vista SP1, don't ask me why, I just wanted to), and the Personal Shared Folders via the Guest additions wasn't working....

Solved it: the guest NAT network is 10.0.2.x and sure enough, I can map drives through the address 10.0.2.2 which is the NAT gateway or domain server (forgot which, but it reaches the host). So now, I can see shared folders on the host through the NAT network, without having to use bridged networking or the VirtualBox additions (installed, but not working for the personal shared folders on a Vista SP1 guest OS for some strange reason). And my host doesn't need to see the guest as an individual IP, so... woo-hoo!