Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a possibility to redirect all traffic to specified hosts behind NAT?

For example i have a server, a domain "" and 3 hosts behind NAT. I wish to configure 3 subdomains:
and each of them to redirect all ports to specified host in local net.

That redirection should provide funcionality like this: (can be achieved using apache)
ssh (???)
and other protocols on diferent ports

Thanks for any help.

share|improve this question
up vote 2 down vote accepted

This can be done for HTTP and HTTPS with a "reverse proxy" that examines the host-header information in a HTTP request, gets the appropriate content and returns it. Microsoft's ISA (Internet Security and Acceleration) can do this, so can apache/squid on Linux.

For all other ports you have a harder time, because most traffic doesn't include the desired hostname, just a target IP (eg: "I want to SSH to" instead of "I want to SSH to

Mapping specific external ports to internal ports is easy (port 22 -> host1:22, port 23 to host2:22, port 24 -> host3:22 etc) and is sometimes all that is needed.

If you really need to map all ports to different internal servers you will need multiple external IP addresses, which most ISPs can provide (at least if you have a business connection)

share|improve this answer

apache mod_proxy ?

share|improve this answer

No, it's not possible to do port forwarding based on DNS name. The domain name is not part of the IP-packet, so there is no way for your router to use this to distinguish incoming connections.

When a remote host connects to it will resolve this name to an IP-adres, which is put in the IP-packet. If resolves to the same IP-adres the constructed packet will look exactly the same as for

For that reason it is possible when you have multiple IP addresses configured on your server.

Apache can distinguish the incoming domain name, but that is on the application level. In HTTP 1.1 a browser will send the domain name in the HTTP headers, on which apache can filter using Virtual Hosts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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