ssh connection slow when using @hostname.com but now when using @ipaddress

Posted by Alex Recarey on Server Fault See other posts from Server Fault or by Alex Recarey
Published on 2010-12-15T19:17:57Z Indexed on 2010/12/23 13:55 UTC
Read the original article Hit count: 470

Filed under:
|

When connecting to a Debian server using ssh, if I use [email protected] (the IP address of hte server) the connection is instant.

If however I use [email protected] (a DNS redirected to the IP address of the server) the ssh connection hangs for a 20 seconds before connecting successfully. The ssh logs show the following:

[alex@alex home]$ ssh -v -v [email protected]
OpenSSH_5.5p1, OpenSSL 1.0.0c-fips 2 Dec 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0

and here it hangs during 20 seconds before continuing.

I think it might have something to do with reverse DNS or similar (the server does not really "know" it's name is hostname.com, it just has that DNS rediriected to its IP address).

I have added the following options to /etc/ssh/sshd_config:

UseDNS no
GSSAPIAuthentication no

to no effect.

The server's DNS records in /etc/resolv.conf are configured correctly:

ping hostname.com
PING sub.domain.com (X.X.X.X) 56(84) bytes of data.
64 bytes from replicant (X.X.X.X): icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from replicant (X.X.X.X): icmp_seq=2 ttl=64 time=0.050 ms?s

Thanks for the help.

Solution: It seems the DSL router my ISP saddled me with was causing the trouble.

Changing my DNS server from 192.168.1.1 (router's IP) to google's (8.8.8.8, always good to know when you are in a hurry) instantly solved the connection delay problem.

I am guessing that the 50€ router provided does not cache DNS entries, although I don't understand why pinging the DNS address had no delay, and 20 seconds is too long of a wait, even for uncached DNS.

Tnanks again for the help!

© Server Fault or respective owner

Related posts about ssh

Related posts about slow