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: > external IP [WAN] > host IP (tiger) [LAN] > virtual client #1 (zebra) > 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


If you simply want to route different ports on 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 on port 80:

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

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 .