TCP连接重置在Linux(奇怪的数据包丢失),但不是在Windows上

这一切都在Windows上,但在Linux上,当我试图检索一个特定的网页,我得到了一个漫长的等待,然后“连接重置由对等”

Pinging目标IP工作正常。

我试图减less接口MTU到1476(发现使用“ping -c1 -M do -s”),甚至更低的值,但它并没有解决问题。

在目标主机附近的另一台Linux PC上,没有问题,所以我怀疑path中有一些路由器。

这些是wireshark和tshark输出:

连接重置的Linux: http : //pastebin.com/tpjS5qZc

Windows没有问题: http : //pastebin.com/iyN1GDxT

看来,第三个数据包在目标主机的path中丢失了,而目的地发回了几个重复的数据包,但是在windows和linux数据包中看不到任何相关的差异。

在你的捕获两台服务器设置“不要碎片位”。 这意味着两端都试图进行pathMTU发现。

似乎有一个防火墙可以阻止你的Linux服务器向远程服务器发送ICMP Fragmentation Needed 。 作为一种解决方法,可以使用MSS进行钳位:

 iptables -A OUTPUT -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu 

您也可以尝试在Linux中禁用P MTU发现:

 echo 1 |sudo tee /proc/sys/net/ipv4/ip_no_pmtu_disc 

iptables手册页:

TCPMSS此目标允许更改TCP SYN数据包的MSS值,以控制该连接的最大大小(通常将其限制为输出接口的MTU减去40,对于IPv4,对于IPv6分别为60)。 当然,它只能与-p tcp结合使用。

  This target is used to overcome criminally braindead ISPs or servers which block "ICMP Fragmentation Needed" or "ICMPv6 Packet Too Big" packets. The symptoms of this problem are that everything works fine from your Linux firewall/router, but machines behind it can never exchange large packets: 1) Web browsers connect, then hang with no data received. 2) Small mail works fine, but large emails hang. 3) ssh works fine, but scp hangs after initial handshaking. Workaround: activate this option and add a rule to your firewall configuration like: iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu --set-mss value Explicitly sets MSS option to specified value. If the MSS of the packet is already lower than value, it will not be increased (from Linux 2.6.25 onwards) to avoid more problems with hosts relying on a proper MSS. --clamp-mss-to-pmtu Automatically clamp MSS value to (path_MTU - 40 for IPv4; -60 for IPv6). This may not function as desired where asymmetric routes with differing path MTU exist — the kernel uses the path MTU which it would use to send packets from itself to the source and destination IP addresses. Prior to Linux 2.6.25, only the path MTU to the destination IP address was considered by this option; subsequent kernels also consider the path MTU to the source IP address. These options are mutually exclusive. 

请参阅: http : //lartc.org/howto/lartc.cookbook.mtu-mss.html

编辑:我仔细看了一下截图之后,发现沿path上有一个破损的防火墙过滤了所有使用TCP Timestamp选项的IP数据包。 只需在Linux上运行: echo 0 | sudo tee /proc/sys/net/ipv4/tcp_timestamps echo 0 | sudo tee /proc/sys/net/ipv4/tcp_timestamps