2

For a centos server hosting a few LAMP virtual machines (using VirtualBox), I have a single external IP. I would like to be able to use this single host external IP to address the virtual machines. Like forwarding ports to specific machines from the outside:

2.2.2.2 > external IP [WAN]
10.0.0.1 > host IP (tiger) [LAN]
10.0.0.2 > virtual client #1 (zebra)
10.0.0.3 > virtual client #1 (mouse)

so external IP is forward via router to host IP (tiger) it will then look at port and send it to zebra or mouse. Both virtual clients might (should) not be using the same ports for Apache etc.

Preferably the routing solution will be done at the host as I have no access to the router itself (but can ask for specific settings if the admin can pull it off)

Hope I'm clear.

1 Answer 1

0

If you simply want to route different ports on 2.2.2.2 to different virtual machines, you can do it with iptables. See the CentOS guide for more details, including how to make rules persistent (iptables only changes settings until the next reboot). To direct incoming TCP requests on port 13080 to 10.0.0.1 on port 80:

iptables -t nat -A PREROUTING -p tcp --dport 13080 -j DNAT --to 10.0.0.1:80

If you want to select the VM depending on the host name in the HTTP request, you need an HTTP server to act as a dispatcher. You can use Apache, but for such a fast, simple task, Nginx is popular.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .