Moh*_*ehe 3 networking linux connection reset tcp
在 Windows 上一切都很好,但是在 linux 上,当我尝试检索特定网页时,我等待很长时间,然后是“对等方重置连接”
Ping 目标 IP 工作正常。
我试图将接口 MTU 减少到 1476(使用“ping -c1 -M do -s”找到)甚至更低的值,但它没有解决问题。
在目标主机附近的另一台 linux PC 上,没有问题,所以我怀疑路径中有一些路由器。
这些是wireshark和tshark输出:
Linux 连接重置:http : //pastebin.com/tpjS5qZc
Windows 没有问题:http : //pastebin.com/iyN1GDxT
似乎第三个数据包在通向目标主机的路径中丢失了,并且目标发回了几个重复的 ack 数据包,但我看不出 windows 和 linux 数据包有任何相关差异。
在您的捕获中,两台服务器都设置了“不要碎片位”。这意味着两端都在尝试进行路径 MTU 发现。
似乎有一个防火墙阻止了ICMP Fragmentation Needed您的 Linux 服务器向远程服务器。作为一种解决方法,启用 MSS 钳位:
iptables -A OUTPUT -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
Run Code Online (Sandbox Code Playgroud)
您也可以尝试在 Linux 中禁用 P MTU 发现:
echo 1 |sudo tee /proc/sys/net/ipv4/ip_no_pmtu_disc
Run Code Online (Sandbox Code Playgroud)
从iptables手册页:
TCPMSS 此目标允许更改 TCP SYN 数据包的 MSS 值,以控制该连接的最大大小(通常将其限制为 IPv4 的传出接口的 MTU 减去 40 或 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.
Run Code Online (Sandbox Code Playgroud)
请参阅:http : //lartc.org/howto/lartc.cookbook.mtu-mss.html
编辑:在我仔细查看捕获后,我发现沿路径有一个损坏的防火墙,它正在过滤所有使用 TCP 时间戳选项的 IP 数据包。只需在 Linux 机器上运行:echo 0 | sudo tee /proc/sys/net/ipv4/tcp_timestamps
| 归档时间: |
|
| 查看次数: |
15249 次 |
| 最近记录: |