I run Ubuntu on my personal machine, and have an network of servers on my local network at my house. I have a cloud server, and a software development server, as well as some others.

My servers have quite a few services which rely on SSH and I have several servers with OpenSSH services running on a few different ports. The internal services are all connected to a domain through DDNS.

The internet that is available for my area is very quick, but it has a bandwidth cap. Let's take a scenario to explain my question.

Say I have a large 10 GB file that I want to transfer from my cloud server to my personal machine and I want to transfer it through SFTP using the Ubuntu OpenSSH client. Say my personal machine is currently connected to the same local network as the server.

My personal machine has some SSH profiles that I use to connect to this server, but they point at "cloud.mydomain.com:22" rather than "". Is the client "smart" enough to know that the domain is pointing to the same external IP it is making the request on and instead route directly to the internal IP, or will I be making the transfer both ways and transferring 20GB of file over my internet connection, rather than just transferring the 10GB file directly?

Description of Network:

Router #1 is the router which provides the internet. All ports forward to Router #2. Router #2 is a repeater bridge with specific ports forwarding to certain IP addresses. (2222 points to the cloud server SSH, 22 points to the development server SSH, etc.) (Set up like this so I can move my setup to a new router #1 and just forward all the ports to Router #2 with one setting.)

The cloud server updates the DDNS every 5 seconds or so. Domain.com points to Router #1, which in turn forwards all external traffic to Router #2. Depending on port, traffic will be routed to whichever server the port is mapped to.

  • since your the ip of cloud.mydomain.com is the public ip of your router, it should route the traffic to the internal network, so you should be fine. Try a traceroute to find out. – user448115 Jun 5 '16 at 20:41
  • Trace-route just returns one hop...that being my external IP. This means you're correct? – Allenph Jun 5 '16 at 21:16
  • @Alleph, yes it means that all traffic is internal to your network. – user448115 Jun 5 '16 at 21:19

SSH client resolves DNS of you domain and it connects to the IP it receives. It does what all the other Internet facing clients. There is nothing about being "smart enough".

  • Well, I know that it resolve the DNS and that I'm pointing to an external IP. I just thought that perhaps the software would say, "Hey, I'm connecting to the same external IP as I'm going out on...let's just ask the router for the internal IP so the networks doesn't have to handle this transfer twice. – Allenph Jun 5 '16 at 20:35
  • It is not clear what you mean by "connected to domain" (image can say more than thousands words). IF you want to "transfer from my cloud server to my personal machine", the data needs to go through isn't it? I don't see any shortcut there. If the cloud server sends the data to some of your local server (as I can make up), your client is unable to find out nor make use of, because it does not know about it. – Jakuje Jun 5 '16 at 20:56
  • I'm adding a description of how the network is set up. – Allenph Jun 5 '16 at 21:09

No, because you are telling it to connect to the external, and that is what it will do.

You might be able to get around this if you have a local DNS server that will check local domain requests from your clients before searching the internet, that might work.

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.