Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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

A Record ftp2.example.com to 123.123.123.123 ---- But on my home router, it will select port 21 as private port to 192.168.0.23 (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 (123.123.123.123) using:

"ssh.example.com" it connects to the ssh server on  ServA using port 22
"ssh2.example.com" 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

1 Answer 1

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 "imap.example.com" "pop3.example.com" "smtp.example.com" while they all just send you to 123.123.123.123? couldn't that be "mail.example.com" 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 "imap.example.com" "pop3.example.com" "smtp.example.com" 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

 
discard

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.