Super User is a question and answer site for computer enthusiasts and power users. 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

I want to use the domain name to select which port it should connect to.

Like: A Record to ---- But on my home router, it will select port 21 as private port to (on the lan side).

A Record to ---- But on my home router, it will select port 21 as private port to (on the lan side).

Another example: I have 2 servers (ServA, ServB) using ssh on port 22. If I connect from WAN to my network ( using:

"" it connects to the ssh server on  ServA using port 22
"" it connects to the ssh server on servB using port 22

I've asked everyone i know with some knowledge, they all say they don't really know..

Anyone here can explain me how this is done?

share|improve this question
up vote 0 down vote accepted

Ports vs internal IP-addresses

The first part of your question talks about ports but the examples are really about translation of IP-addresses. These are very different things.

Domain names and forwarding

You cannot use domain names of servers to specify address translation to be carried out by routers.

The FTP protocol doesn't carry information about the domain-name(if any) used to make the connection.

Neither does SSH so far as I can tell, and SSH payload is encrypted anyway so inaccessible to routers between client and server.

The HTTP protocol does (in the Host:header), but routers do not look at that level of detail.

share|improve this answer
Any ideas how I can connect to different ssh servers within my lan from outside my lan? Without using different ports? And why would u need "" "" "" while they all just send you to couldn't that be "" for all the domainnames? – Marco Nov 23 '12 at 21:18
The only way I know of is to use different port numbers. An exception would be if your ISP can allocate a block of static IPs to your router. Alternatively use SSH tunnelling or forwarding. I just SSH to my main server then ssh from there to the others. – RedGrittyBrick Nov 23 '12 at 21:20
I edited my comment just a sec too late – Marco Nov 23 '12 at 21:23
Yes, if "" "" "" all point to the same IP-address you can use any name for any service. The point of domain names is to make it easy for service providers to move services between servers as needed for maintenance, scaling or other reasons. (Apart from being easier to remember of course) – RedGrittyBrick Nov 23 '12 at 21:25
Thank you, this helped me a lot. – Marco Nov 23 '12 at 21:48

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.