0

I have a remote machine that is often on the same local network as the machine I'm using and that I can refer to using either a domain name or a local IP address. Does how I refer to it affect latency or throughput?

For example, when I want to ssh to this machine, lately I've been using a shell script which first checks if I'm on the same local network and if so it uses the local IP address and if not it uses the domain name. Does this script in any way speed up the connection when both machines are on the same local network?

2 Answers 2

1

What can cause a difference is different IP addresses and different routing for the IP addresses. If that is actually the case or not depends on your setup.

Try host remote_machine_name and see to which IP address it resolves. If that is not the same as the local IP address (for example because the remote machine is behind a public address with NAT, and because remote_machine_name resolves to that public address), and if traceroute does show hops through external networks for this address, then yes, using the local IP address is faster, and it might be worth making a script to check for that.

Another solution is to set up DNS so it returns the local IP address if reachable, etc.

1

If you refer to the machine by hostname, your local machine will need to do a DNS lookup in order to find the IP address. Theoretically this would cause a tiny amount of latency, but you would never notice it. It happens in less than one second. After a successful lookup, it'll be cached on your local machine for 86,400 seconds (1 day), or until a reboot. In short, your script is really unnecessary.

4
  • 1
    In fact, depending on how many times the script runs, the little latency the script adds could add up to more than the latency of a DNS lookup.
    – Ron Maupin
    Commented Oct 1, 2016 at 2:06
  • Once the DNS lookup has been done, does the connection need to go over anything but the local network? Commented Oct 1, 2016 at 2:24
  • No. You could disconnect your LAN from the internet and you'd still be able to communicate between any points on your local network, even before the DNS lookup occurs. Commented Oct 1, 2016 at 9:40
  • How can I see evidence of this? traceroute shows 12+ hops if I use a url even though the two computers involved are on the same LAN. Commented Aug 30, 2017 at 4:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .