I want to host several websites using the same IP address. My ISP gives me one static IP address, however I have three different webservers (all running different sites) hooked up behind a cheap switch that all are ultimately behind this one IP address (I one is apache, and two are windows boxes, so I can't really consolidate them). I can do port forwarding with this switch based on port and incoming IP address, but not hostname. This isn't a long term solution since the only way to differentiate which webserver I'm trying to get to is via port. And that's ugly.

I also have a linux box with two network cards that I'm hoping to use as a more robust firewall/router. My question is - what is the best way to turn my linux box (running Xubuntu) in to a router that will be able to route based on host names and not just IP addresses? I want to leave Xubuntu on the box though, so no dedicated router linux distros please.

I looked at Shorewall, but I couldn't find a way to get it to route packets based on host name instead of IP address. Is IPTables the way to go? If so, could someone point me to a tutorial or something on how to do this? I googled and I was shocked that this is not a more commong scenario!

  • You're confusing Shorewall and IPTables. IPTables is the Linux firewall; Shorewall helps you configure and set up the Linux firewall - Shorewall uses IPTables to do this. Previously, Linux used IPChains - but Shorewall worked with IPChains back in the day as well.
    – Mei
    Jul 12 '10 at 4:52

It is not possible to route based on hostname. The whole concept of DNS is something which exists on a higher level than basic network traffic does.

(For more info, read about the OSI model in general and the TCP/IP model in particular.)

On the other hand, the HTTP protocol does know about hostnames. Hence you should be able to setup a reverse proxy on the external address, forwarding requests to different internal addresses, based on incoming hostname. One option is to use Apache and mod_proxy.

  • +1 for reverse proxying, this is exactly the sort of thing it's made for
    – David Z
    Jul 12 '10 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.