restrict shared folders on virtualbox?

2

I'm a bit rusty on virtualbox.

I have a VM with this setup

You see an icon to access the Host machine, and the C drive available.

enter image description here

I would like to temporarily amend that to just a particular folder available

I see an option here for adding a particular folder from the host as a folder on the virtual machine.

enter image description here

But that option doesn't seem that relevant to me because I already seem to have the host's whole C drive available from the virtual machine.

What i'd like is, temporarily, to have only the host's folder viewable from the VM, rather than the host's whole C drive viewable/accessible from the VM.

(It's a Win7 host and a Win XP VM but that's perhaps not relevant)

UPDATE ADDED

Heavy has pointed out this is Windows File Sharing. He's right.

So the question is, How can I restrict a virtual machine from using Windows File Sharing? I want to make this restriction at the host, rather than the VM itself

On the host machine, we see the connection (the guest machine is really 10.x.y.z but virtualbox is putting it behind [virtual] NAT so it's showing as 192.168.56.1). My host IP is 10.x.y.z though virtualbox installs a virtual network adaptor 192.168.56.1

enter image description here

I have tried these two firewall rules but they haven't worked. (An outbound rule and an inbound rule).

The protocols and ports tabs (and maybe my error is here) shows enter image description here

and

enter image description here

We see here they haven't worked

The Guest can still see port 445. nmap run from guest

file sharing still works.

enter image description here

barlop

Posted 2015-10-13T06:11:44.477

Reputation: 18 677

You're currently using the built in Windows network File and Printer Sharing, not the VirtualBox Shared folders. The VB shared folder will show up under the server name VBoxSvr – heavyd – 2015-10-13T06:24:45.037

Use the NORMAL Windows Firewall controls to disable file sharing if you don't understand how the advanced settings work (which you don't). Alternatively, don't share your entire C: drive to begin with. – qasdfdsaq – 2015-10-15T13:08:04.817

@qasdfdsaq i've always used the "advanced" rules no problem, (though up till now it has only been to allow/block inbound connections from unwanted IPs), so local IP is then the interface the service is bound to. I don't know what "normal" rules you are referring to. Could you elaborate – barlop – 2015-10-15T21:02:01.647

@Barlop: Control Panel => Windows Firewall => Allow Program or feature through Firewall. I'm suggesting it because you seem unaware of the existing advanced rules to allow file sharing since you've tried to create a rule to block a port that conflicts with multiple wider rules to allow the same port. – qasdfdsaq – 2015-10-16T19:00:01.563

@qasdfdsaq I simply forgot about the existing default/native rule for file sharing.(With XP it was easier to see because there were less native/default rules. Win7 has a load of rules to wade through. Out of sight, out of mind). Next time i'm in front of the comp in question, i'll look at / amend the existing rule and delete the new ones I created – barlop – 2015-10-16T19:42:30.987

And therein lies the difference. In the In the normal Windows Firewall control panel there is just one rule and two checkboxes for file sharing. In Advanced settings there are 18. – qasdfdsaq – 2015-10-17T23:52:41.653

Answers

1

  1. Disable Windows file sharing on the host
  2. Set a shared folder in the Virtualbox Guest settings

SPRBRN

Posted 2015-10-13T06:11:44.477

Reputation: 5 185

I did write "I want to make this restriction at the host, rather than the VM itself" – barlop – 2015-10-13T13:07:06.887

Sorry, overlooked that. Anyway - you should disable Windows File Sharing wherever you don't want that. In this case: the host. – SPRBRN – 2015-10-13T15:15:13.957

The reason why I don't disable windows file sharing on the host, is obviously because I want it enabled, because I want to use it, it's just for that VM that I don't. It looks like I have an idea of the solution/problem now though, just amending the existing native file sharing rule – barlop – 2015-10-16T19:45:51.860

I don't have a Windows machine here, but can't you block the specific IP of the guest machine on the host firewall? This will only work if the IP is fixed. Even though DHCP will reserve a specific IP for each machine on the network, that can change over a longer time. – SPRBRN – 2015-10-16T23:13:23.583