Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to set up a Linux virtual machine using Virtualbox on OS X in the following way:

  • I'd like to use a virtual network, with my physical machine acting as a NAT to the wider internet / other networks. So, my virtual machine should have an IP address which is visible from my physical machine (I can browse to http://172.something/ and see a web server running on the virtual machine) but other machines on my physical network should NOT be able to see the virtual machine.
  • I'd like the virtual machine to be able to see "out" - it should be able to access resources on the rest of my network and on the internet as a whole.

I'm not interested in bridged networking (where the virtual machine gets an IP address on my physical network). I switch networks a lot and will be running this on a laptop, so anything that breaks if I switch from ethernet to WiFi or back again is bad.

I've tried pretty much every combination of network settings in Virtualbox and I haven't managed to get both of the above bullet points working at once - I can set up a private network behind NAT but then the virtual machine can't see the internet. I can get the virtual machine to see the internet but then I don't seem to get an IP address that my physical machine can use to access servers running on the virtual machine.

I've managed to get this setup working in both VMWare Fusion and Parallels without any trouble - any ideas how to get it working in Virtualbox?

share|improve this question
    
I must be missing something, but if you want your host machine to be able to see the virtual machine, and your virtual machine to see the outside world - what you are describing really is working with an adapter in bridged mode (of some sort). –  Goyuix Sep 10 '09 at 17:39
add comment

1 Answer 1

Please see the following question that was asked: Port forwarding to virtual machine

In a nutshell, you will want to configure your VM network adapter to be in NAT mode, then issue the following management commands:

VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8888
VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata VM_NAME "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.