Configure router to redirect different hostnames to different machines

5

1

Is it possible to tell your router to redirect specific domains to a specific IP? The router is an Airport Extreme, unfortunately. If it can't be done with this specific router, is there another way to achieve this?

oskob

Posted 2011-12-09T10:26:40.027

Reputation: 153

I love this question because when developing a website locally and trying to test it from an iPhone on the LAN, I'd love not to need to browse to the specific IP address of my server (and instead use a hostname). I.e. the solutions here are terrible and would be solved by an answer to your question: http://stackoverflow.com/questions/3132105/how-do-you-access-a-website-running-on-localhost-from-iphone-browser

– Ryan – 2017-01-24T23:49:16.773

Answers

2

I have configured many routers and have never seen a feature like this in off the shelf routers. As far as I know you only get these types of features on high-end enterprise routers like SonicWall and Cisco routers. These range in prices, but the SonicWall I used had this feature and was about a $3,000 router.

This is really an advanced task your trying to accomplish. If your up for it you can buy a router compatible with DD-WRT or OpenWRT and get that type of feature for under $200 buck. you gotta flash it and then go from there.

@Dan offers another option which is software based, which may be the easiest method depending on how large of a network and how many servers you have behind that router. You may be able to configure Apache as a proxy and forward request to other internal Apache servers.

Apache mod_proxy - http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

Nickiler

Posted 2011-12-09T10:26:40.027

Reputation: 146

Does anyone know if its is actually possible to do this on a SonicWall, what the feature is called, and how to determine which models support it? – Robert Noack – 2015-07-27T17:20:45.850

Is this something that PFSense might be able to do? I've used it as a router before, but it's been some years since I last messed with it.

– Melikoth – 2011-12-09T13:22:22.047

I never used PFSense before, but skimming thru the docs and wiki, PFSense appears to be much more advanced than your standard router. – Nickiler – 2011-12-09T16:09:01.637

1

As previously mentioned, it's impossible for most routers.

However, there are always other methods, which I felt might be valuable to those that land on this topic:

For those that want to accomplish this for INCOMING requests to a server, it is possible through another, FREE, method:

You could have 1 main server ACT as your router. Let me explain. If you are using Apache, you have the built-in ability to host multiple domains as a "Virtual Host" - If your server has enough resources to handle it, you might be better off with multiple directories on 1 server. You can configure Apache to listen on the same IP for multiple "ServerName" (domains), while pointing to different directories.

If you wanted to have files for each domain on a separate server, you could setup a network share, and point that "ServerName" to that the NFS or SAMBA mount. With either setup, you are dependent on the main server's resources, as that is where the processing will take place.

For those that want to accomplish this for OUTGOING requests, from a client computer, it is possible through another, FREE, method:

On your computer, with admin privileges, edit your /etc/hosts file, basically just insert a new row with your destination IP and the domain name you want to point there:

127.0.0.1 yourdomain.com

Here's a pretty good how-to for all OS's: http://support.hostgator.com/articles/general-help/technical/how-do-i-change-my-hosts-file

webaholik

Posted 2011-12-09T10:26:40.027

Reputation: 121

0

No, to be frank. Definitely not with an Airport Extreme, and I doubt with any other kind of consumer or prosumer router. This isn't what routers are designed for - that kind of 'routing' needs to be done by software on an Operating System.

To be honest, I'm not even sure if there's ANY router that would do - but I'm always happy to be shown.

Edit: Wait, I assume you're talking about redirecting INCOMING connections? What is it you're trying to achieve exactly?

Dan

Posted 2011-12-09T10:26:40.027

Reputation: 1 068

Yeah, incomming connections. I want two domains pointed at the same ip but be hosted on 2 different machines. – oskob – 2011-12-09T11:39:50.360

@oskob: That's not going to work in general. Incoming packets have an IP address on them, but no hostname. So, if you have a.example.com and b.example.com both resolve to 1.2.3.4, then you can't tell from an incoming packet to 1.2.3.4 what hostname the remote side used. HTTP is a special case; you can set up a reverse proxy. That's not a router task, though. (wrong OSI level) – MSalters – 2011-12-09T15:40:17.940

0

No, routers don't support redirecting on domain names since they work on layer 3 of the OSI model. That means that they route network traffic based on IP-adresses and IP-adresses don't contain host-names nor domain-names since that's done on layer 5 (session) of the OSI model, see: http://en.wikipedia.org/wiki/OSI_model If you want to route to domains you probable have to think of using a vlan or subnet. Those settings you likely don't find on cheap routers.

Ezeyme

Posted 2011-12-09T10:26:40.027

Reputation: 26