Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 8.8.8.8#53 resolving 137.161.97.23.in-addr.arpa/PTR for client 127.0.0.1#37839: 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 137.161.97.23.in-addr.arpa 207.46.75.254 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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 127.0.0.1 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). –  Marcin Wisnicki Mar 11 '14 at 0:45
1  
Your IP (23.97.161.137) 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. –  Marcin Wisnicki 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. –  Marcin Wisnicki Apr 17 '14 at 12:30

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.