Page 1 of 1
Mapping an external port to the VM
Posted: 14. Dec 2009, 23:49
by shadowdemon
My host is Ubuntu Karmic i386 Server. I want to run my webserver in a VM. I have configured the VB NAT so that the VM port 80 is mapped to the host 8080 (as host 80 doesn't work). The mapping is done to the localhost IP, but what I need is to map the port 80 of the Internet IP of the host to the port 80 of the VM. So the missing step should be to map the IP:80 to localhost:8080. I have the host FW configured with UFW, rather then iptables. Google says that I need this:
Code: Select all
/sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp –dport 80 -j REDIRECT –to-port 8080
Unfortunately, it doesn't work. I can wget my VM on localhost:8080, but pointing a browser to my IP doesn't work, even if port 80 is open in UFW.
Any clue how to get this done?
Re: Mapping an external port to the VM
Posted: 15. Dec 2009, 00:43
by Perryg
You say your host is Ubuntu but your profile does not match. So the next question needs to be what is the guest?
If this is to have the guest and the host appear to be in a real network why not use host-only as one adapter and a second one for NAT to allow Internet access?
Re: Mapping an external port to the VM
Posted: 15. Dec 2009, 13:59
by shadowdemon
Thank you for the tip on my profile. I haven't been in this forum for a while, and things have changed.
In the case I am trying to solve, both the host and the guest (more to come) will be Ubuntu Server i386 9.10 (until next LTS comes out).
I have two Internet IP (I mean REAL public IP addresses, not LAN addresses), one for the "general public" and one for "internal use". The the first one should be mapped to the ports of one or more VMs, and the second one is used by the host itself. I do not want the guests to have their own Internet IPs, as I would have to pay for each one.
If I use NAT, then I have to map a public IP port to a localhost port. And if I use host-only adapter, then I have to map a public IP port to internal, host-only visible, non-localhost port.
(Assuming I got it all right).
Is there an advantage to the one or the other?