PDA

View Full Version : [ubuntu] Slow ping and ssh from ubuntu; fast from windows



kedomingo
April 17th, 2012, 04:31 AM
I have googled the issue and most suggest that this is a problem with ping's reverse DNS lookup and an -n option will solve this. However, ping is not the only problem but ssh as well.

To illustrate, I have 2 clients on the same network: let's call them UBU(10.0.0.106) and WIN(10.0.0.103) -- Ubuntu 11 and Windows 7 respectively. The following settings are the same for both machines:


Gateway: 10.0.0.1
DNS: 10.0.0.1, 10.0.0.50


Pinging a FQDN from WIN is fast as expected but from UBU, it is verrry slow. This can be sped-up by disabling reverse DNS lookup of ping:


vgm@sandbox ~ $ ping -n example.com -c 4
64 bytes from x.x.x.x: icmp_req=1 ttl=49 time=210 ms
64 bytes from x.x.x.x: icmp_req=2 ttl=49 time=206 ms
64 bytes from x.x.x.x: icmp_req=3 ttl=49 time=208 ms
64 bytes from x.x.x.x: icmp_req=4 ttl=49 time=220 ms


An ssh connection from WIN to the same FQDN is also fast, but from UBU, it is painfully slow (the server responds after about 10-60 seconds). I also already turned reverse dns lookup from the server i'm ssh-ing to (using UseDNS). Note that this server i'm connecting to is not on the local network but somewhere in the UK and assumed to be properly set up.


vgm@sandbox ~ $ time ssh example@example.com
example@example.com's password:


real 0m43.788s
user 0m0.012s
sys 0m0.004s


From the remote machine:

# cat /etc/ssh/sshd_config | grep DNS
UseDNS no


Although hostname lookup is fast from UBU:


vgm@sandbox ~ $ time host example.com
example.com has address x.x.x.x
example.com mail is handled by 0 mail4.atlanticbt.com.

real 0m0.481s
user 0m0.000s
sys 0m0.012s


Firewall is also disabled on both machines.

Could you guys give me some insights why this is happening?

(*I have replaced my FQDN with example.com)

sj1410
April 17th, 2012, 07:57 AM
there are 2 tweaks which helped me for slow ssh connection,

Fix for slow SSH connection (http://www.techpage3.com/2012/04/fix-for-slow-ssh-connection.html)