Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed ubuntu server inside a virtual box(11.04), then i configured apache.

Inside virtual box setting, i made a port forwarding from port 80(host) to 80(guest), i open my web browser on my host, and i go to http://localhost DON'T work, but if i go to http://localhost:1080, it work, but i didn't make a port forwarding from 1080 to 80, i have no 1080 in my configuration, what i want to know is why it does this?

I know that port 80 won't work until i launch the virtualbox as root, but what i don't know is why does it actually transform the port 80 to 1080 when it could just not work... is there something in virtualbox that see when its not root and transform address below 1024 to something else?

share|improve this question

2 Answers 2

The VirtualBox manual says:

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.

I guess this is the reason for getting port 80 forwarded properly when the host was run as a root user. Anyway I am not sure why the port is changing automatically from 80 to 1080.

share|improve this answer

There is a nice section explaining port forwarding with NAT on Virtualbox here:

http://www.virtualbox.org/manual/ch06.html#natforward

I am not sure why your are seeing the behavior you are, can you post your configuration ?

The other (potential) solution is to use bridged networking. Personally I find bridged networking is easier to configure. If I feel I need a firewall, I configure it from the guest. You can easily limit port 80 to your host or lan with ufw.

sudo ufw enable
sudo ufw default deny
# change "192.168.0.10" to your host
sudo ufw allow proto tcp from 192.168.0.10 to any port 22
# Or for you LAN
sudo ufw allow proto tcp from 192.168.0.0/24 to any port 80

You can change "any" to your IP if you wish.

share|improve this answer
    
I already have read that page, but i have nothing configured for 1080, and i want to know why it 80 become 1080 when its not configured... –  user1115057 Jan 14 '12 at 22:11
    
I can not tell much without additional information. Please post your configuration information, the commands you used, or screenshot. –  bodhi.zazen Jan 14 '12 at 22:20
    
virtualbox->network->portforwarding: RULE1 UDP "" "80" "" "80" RULE2 TCP "80" "" "80" the empty field mean any IP, so no 1080... i open up my web browser in my host, and i have to type localhost:1080, else it don't work –  user1115057 Jan 14 '12 at 22:28
    
Did you try deleting that entry and running sudo VBoxManage modifyvm "Your VM name" --natpf1 "guesthttp,tcp,,80,,80" ? –  bodhi.zazen Jan 14 '12 at 22:36
    
i just finished transferring my virtual machine to root folder, now running from root, if i type localhost:1080, not working anymore, only port 80... strange behavior when not working with root privilege, maybe every program trying to use port 80 when not root are automatically remapped to port 1080... –  user1115057 Jan 14 '12 at 22:50

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.