I'm running an http(zope) server on Ubuntu 8.04 server, in a Virtualbox machine, on an Ubuntu 9.04 box. The guest system accesses network over NAT. How can I forward the host machine's port 80 to the guest system's http port?
You have to enable port forwarding in VirtualBox. You can do that by using the
VBoxManage command. For example:
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
In this case, this will open port 8888/tcp on your host (physical machine), and forward it to port 80/tcp of your virtual machine (replace VM_NAME with the name of your virtual machine).
For more details, see "Configuring port forwarding with NAT" in the VirtualBox User Manual (section 6.4.1, p. 84)
If you need external access to the web server hosted on your virtual machine, then you'd also need to create a port forwarding rule (for example through
iptables or configuring it in your router).
figure out what ip address has the guest system (though it's dhcp assigned, it's more likely it will have the same address after reboot; if not, switch to static ip's)
iptables -t nat -A PREROUTING -s 0/0 -d IP_HOST -p tcp --dport 80 -j DNAT --to IP_GUEST:80