Delay in SSH connection in Ubuntu Feisty

I just grew fed up with all of my ssh connections taking more than 15 seconds before a connection was established. I ruled out the usual suspects:

  • Misconfigured DNS can cause it as a reverse lookup times out. This however was not the case. dig -x [ipaddress] worked fine on the server.
  • When ipv6 on the workstation is misconfigured it can cause the problem because ssh will try to connect over ipv6 before connecting thru ipv4. I disabled ipv6 (alias net-pf-10 off in /etc/modprobe.d/aliases) but still no go. I could have guessed since my ipv6 route table was empty..

I fired up wireshark and traced a connection. The cause of the problem was mdns which did lookups that timed out. $DEITY knows why it does; I just disabled it by removing all references to mdns in /etc/nsswitch.conf - and all works fast again

Wireshark is great.


Worked great

I commented out the following line (added # in the front)
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

and added the following line.
hosts: files dns

my nssswitch.conf file looks like this:

# /etc/nsswitch.conf
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis

Thanks for the help!
Ubuntu Desktop 10.10 amd64

It works!!

Thanks very much for providing this tip - works a treat when creating an ssh connection to my Karmic machine!

Thank you :)


Thanks so much for posting this. I was having the same problem, and it was driving me nuts!

Thank you.

It would've taken me forever to figure this out.

Works on Gutsy

I just tried this in Gutsy Gibbon after trying disabling ipv6 but my ssh connection still took 15 seconds to connect. After commenting out mdns it's under a second!