Whenever I try to connect to my server from Azure VM it takes a lot of time due to failing reverse DNS lookup.

I can disable lookups with UseDNS no and completely bypass the problem but this makes logs less useful so I'd rather not do it that way.

I'm also running local BIND server for caching and serving local zones.

What I've noticed is that whenever SSH client sends username, named emits multiple warnings like:

Mar 10 22:56:04 ghost named[1813]: DNS format error from resolving for client invalid response

This is repeated for every server configured as forwarder as well as for microsoft servers serving that zone. Then there is a 1s pause and the whole thing repeats 4 times.

If I execute nslookup -type=ptr -nosearch -d2 similar warnings happen but they are not repeated 4 times.

So my questions are:

  1. Why is this response not cached ?
  2. Why does sshd retry it 3 times ?
  3. Can I do something about it ?

UPDATE I know my client machine has no PTR record but it's perfectly valid for client to not have one. Besides I have no control over DNS records of client machines.


Depending on your use case and what exactly you are trying to avoid by not fixing either your DNS or your ssh config, you can modify hosts files on your servers to report the name and IP to sshd.

It isn't cached because nslookup doesn't use your system's resolver (only the entries in resolv.conf), if you are, in fact, running a caching name server locally. By default, there is no local cache on Linux servers. Common ones include nscd, sssd, and bind.

  • But fixing my SSH and/or DNS is exactly what I want to do! Can you suggest what might be broken in my configuration ? I have in resolv.conf - if I didn't there would be no problem (see that named warning/error I posted above - it's a proof that sshd used local named for resolution). Mar 11 '14 at 0:45
  • 1
    Your IP ( doesn't have a PTR record. Add one or have MSN, who is the SOA for this zone, add one.
    – Ben
    Mar 25 '14 at 18:53
  • I know that but adding PTR record is not an option, besides no relevant standard mandates that. Mar 25 '14 at 20:57
  • You have declined to use every option I know. Fix your sshd.conf, fix your DNS, or add an entry to your /etc/hosts file. How does UseDNS no make logs less useful?
    – Ben
    Apr 16 '14 at 23:44
  • UseDNS no disables address resolution for all hosts which makes log less readable. The problem is that failing dns resolution takes too much time to timeout and I don't know how to fix it. Apr 17 '14 at 12:30

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.