can't make NAT work

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
bhomass
Posts: 7
Joined: 31. May 2012, 06:56

can't make NAT work

Post by bhomass »

I have a virtual box running on OS X host. The guest OS is Ubuntu. I want to set up the VM to use NAT. The VM setting part was easy. adapter 1 is set to NAT.

in the host, I entered VBoxManage modifyvm "myvm-name" --natpf1 "guesthttp,tcp,,80,,80"

the command went thru fine, no errors. Then I start the VM and try typing localhost into a browser on the host. no response on it. I verified that apache is running on the guest. so, the port forwarding is failing.

If all works as I wanted, I would like to have all port 80 request on the host to be forwarded to the VM.

Any one can tell what I am doing wrong?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: can't make NAT work

Post by socratis »

bhomass wrote:Any one can tell what I am doing wrong?
Yes, the user's manual, Chapter 6.3.3, NAT limitations:
Chapter 6.3.3 wrote:Forwarding host ports < 1024 impossible:
On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible to bind to ports below 1024 from applications that are not run by root. As a result, if you try to configure such a port forwarding, the VM will refuse to start.
BTW, you posted in neither "Mac OS X Hosts" nor "Linux Guests" forum, but on "Linux Hosts" ;)
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
bhomass
Posts: 7
Joined: 31. May 2012, 06:56

Re: can't make NAT work

Post by bhomass »

sorry about wrong subforum. I am first time poster.

so, are you saying I need to run my apache as root, then forwarding of port 80 would work?

or does it mean the browser requesting localhost:80 (on Mac) needs to be launched by root? normally, the req will be coming from outside the host, so I don't understand this limitation. just who needs to be root?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: can't make NAT work

Post by Perryg »

Never run anything as root. What you can do is use host-only and access the guest from the host or if you simply want to use NAT then use a port that is higher than 1024 Forward something like 8080 and then configure the server to handle requests on 8080.
bhomass
Posts: 7
Joined: 31. May 2012, 06:56

Re: can't make NAT work

Post by bhomass »

reconfigured apache on guest to port 8011

on the host, VBoxManage modifyvm "myvm-name" --natpf1 "guesthttp,tcp,,80,,8011"

still no response when I enter http://localhost on host's browser.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: can't make NAT work

Post by mpack »

Moved to OS X hosts.
bhomass
Posts: 7
Joined: 31. May 2012, 06:56

Re: can't make NAT work

Post by bhomass »

I got it now. the 8011 needs to be on the host side, not the guest side.

This really puts me in a bind. The whole idea is that the host will server up a web site from the guest when it receives an external web request. Of course, that request will be in port 80. It would be useless to change that input port request to 8011.

The only option then would be making the request come from root. But how would I do that? the request comes from an external source. It is not an app that is running on the host.
Post Reply