无法build立两个服务器之间的networking连接

我有7个运行在EC2上的Ubuntu 14.04.4服务器。 一台服务器承载了memcached(端口11211),另外一台是客户端。 在6个客户中,有5个能够连接,一个不能(见注)。

我已经采取了连接两端的TCP转储。 我看到客户端发送了SYN请求,但是没有发送ACK。 对于失败的连接,tcpdump看起来像这样(在这之后,SYN重复多次)

1 0.000000 172.16.1.58 172.16.1.94 TCP 76 43469 → 11211 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=849737 TSecr=0 WS=128 

而对于不同服务器的成功连接:

 1 0.000000 172.16.1.64 172.16.1.94 TCP 76 44908 → 11211 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=19201098 TSecr=0 WS=128 2 0.000298 172.16.1.64 172.16.1.94 TCP 68 44908 → 11211 [ACK] Seq=1 Ack=1 Win=29312 Len=0 TSval=19201098 TSecr=3160738522 

一些更多的痕迹和命令:

 working-client$ nc -vnz 172.16.1.94 11211 Connection to 172.16.1.94 11211 port [tcp/*] succeeded! broken-client$ nc -vnz 172.16.1.94 11211 nc: connect to 172.16.1.94 port 11211 (tcp) failed: Connection timed out broken-client$ nc -vnz -q 5 -u 172.16.1.94 11211 Connection to 172.16.1.94 11211 port [udp/*] succeeded! 

路由表(在所有客户端和服务器上相同)

 $ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default ip-172-16-1-1.e 0.0.0.0 UG 0 0 0 eth0 172.16.1.0 * 255.255.255.0 U 0 0 0 eth0 

破损的客户端上的IP表

 broken-client$ sudo iptables -nvL -t nat -------------------------------------- Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination broken-client$ sudo iptables -nvL -------------------------------------- Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 

服务器上的IP表

 server$ sudo iptables -nvL -t nat -------------------------------------- Chain PREROUTING (policy ACCEPT 7332 packets, 531K bytes) pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT 7332 packets, 531K bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 370 packets, 25781 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 370 packets, 25781 bytes) pkts bytes target prot opt in out source destination server$ sudo iptables -nvL -------------------------------------- Chain INPUT (policy ACCEPT 1963K packets, 341M bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 2670K packets, 5518M bytes) pkts bytes target prot opt in out source destination 

所有的客户都是从相同的基础图像克隆,应该是相同的。 我们没有使用iptables,所有的服务器都在同一个子网和安全组上。

问题不在于memcached:我可以用telnet(端口22或端口11211)或ssh重现问题,虽然它们被安全组所允许,但都不允许连接。

Ping是禁用的,但我可以在服务器之间进行跟踪路由(caching<=>客户端,客户端<=>caching),只要它不是这两个服务器即可。

它看起来(请参阅上面的跟踪)可以build立UDP连接,但不是TCP。

问题是持久的。

注意:6个客户端服务器是自动扩展组(在VPC中)的一部分。 有1到6个服务器,根据负载,有时一个服务器无法连接。 IP地址和服务器名称得到重用。

我可以看看哪些连接失败?

这似乎是由新的Linux内核中的ARPcaching(MAC地址caching)引起的。

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1331150