我有一台Ubuntu 12.04笔记本电脑,连接到不同的服务器(在不同的数据中心)需要这么长时间才能真正获得连接。 如果我连接到服务器之间它是瞬间的,我已经设置
UseDNS no AddressFamily inet
在我要连接的服务器上(并重新启动以获得更好的效果)。 我也把我连接的电缆连接反向DNS + IP。 如果我通过telnet从笔记本电脑连接:
telnet my.server 22
那么连接也是即时的,所以对于中间防火墙来说这似乎不是问题。 我有相同的行为,无论我连接的IP,在我的主机或FQDN短名称。 我连接的是50Mbps(电缆,同步)连接,所以看起来不是问题,当我最终得到连接时,它是一个好的,快速的,稳定的连接。 我试着听另一个端口(8000),这没有什么区别。 Web和从笔记本电脑到机器的其他连接也非常好。
如果我增加日志logging,那么在挂起之前我会得到以下内容:
$ ssh -vvv flip OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012 debug1: Reading configuration data /home/anton/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to flip [xxx.xxx.xxx.xxx] port 22. debug1: Connection established. debug3: Incorrect RSA1 identifier debug3: Could not load "/home/anton/.ssh/id_rsa" as a RSA1 public key debug1: identity file /home/anton/.ssh/id_rsa type 1 debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048 debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048 debug1: identity file /home/anton/.ssh/id_rsa-cert type -1 debug1: identity file /home/anton/.ssh/id_dsa type -1 debug1: identity file /home/anton/.ssh/id_dsa-cert type -1 debug1: identity file /home/anton/.ssh/id_ecdsa type -1 debug1: identity file /home/anton/.ssh/id_ecdsa-cert type -1
它挂在以下两行之间的服务器上:
Nov 6 13:51:57 srv sshd[18472]: Connection from XXX.XXX.XXX.XXX port 51099 Nov 6 13:53:03 srv sshd[18472]: debug1: Client protocol version 2.0; client software version OpenSSH_5.9p1 Debian-5ubuntu1.1
这比昨天至less快一点!
有没有人有任何想法吗?
这些症状是你在PMTU发现中断时所能看到的。 客户端可以连接和版本信息交换没有问题,因为所有的数据包都很小。
但一旦密钥交换开始发送更大的数据包。 如果一些中间路由器在没有发送标准所要求的ICMP错误消息的情况下丢弃较大的数据包,则发送方永远不会知道数据必须以较小的段发送。 因此连接停在第一个大包上。
如果确实是这个问题,那么降低MSS或MTU可以解决这个问题。 第一步可以是在连接的每一端修改使用的路由表项以包含advmss 1220 。 或者,如果您不想修改默认路由,您可以简单地使用相同的网关添加更具体的路由。
你提到这个问题本身就消失了,这对于一个MTU问题也不是不可能的,因为当BGP决定通过另一个不通过有问题的路由器的path发送你的数据包时它可以消失,或者由于pipe理员负责有问题的路由器注意和解决问题。