我在 TCP 连接中遇到了非常奇怪的行为。 使用以下命令创建监听器:
ncat -4 -l 10000
发送数据:
telnet Public-IP 10000
使用tcpdump
分析数据并使用netstat
检查连接状态。当我发送数据包时(1、2、3、4、5 ....等等)。在服务器端只收到 4 或 5 个数据包然后什么也没有发生。
tcpdump 未显示任何即将到来的数据包,而 netstat 显示“已建立”连接状态。
ncat public-ip 10000
命令也会发生同样的事情,ehrn 将其用作客户端。
当我使用 telnet 命令 wih ^] 退出并退出
时,telnet 无法连接到服务器(错误:连接被远程主机拒绝)。如果我将终止 ncat -4 -l 10000
命令并再次重新启动,那么将从客户端 (telnet) 建立连接并且服务器将仅收到 4-5 个数据包。
我已经通过 this url 交叉检查了所有 tcp 参数
谁能知道服务器端发生了什么,我该如何调试它?
编辑:1:
客户端机器上的TCPDUMP
//Data-pkt-3
13:26:55.844538 IP (tos 0x10, ttl 64, id 37219, offset 0, flags [DF], proto TCP (6), length 55)
10.240.8.230.53839 > PUBLIC-IP.PORT: Flags [P.], cksum 0x9660 (correct), seq 9:12, ack 4, win 229, options [nop,nop,TS val 301276907 ecr 436759593], length 3
//Data-pkt-4
13:26:59.916512 IP (tos 0x10, ttl 64, id 37220, offset 0, flags [DF], proto TCP (6), length 55)
10.240.8.230.53839 > PUBLIC-IP.PORT: Flags [P.], cksum 0x8035 (correct), seq 12:15, ack 4, win 229, options [nop,nop,TS val 301277925 ecr 436763991], length 3
13:27:00.179644 IP (tos 0x10, ttl 64, id 37221, offset 0, flags [DF], proto TCP (6), length 55)
10.240.8.230.53839 > PUBLIC-IP.PORT: Flags [P.], cksum 0x7ff3 (correct), seq 12:15, ack 4, win 229, options [nop,nop,TS val 301277991 ecr 436763991], length 3
13:27:00.443650 IP (tos 0x10, ttl 64, id 37222, offset 0, flags [DF], proto TCP (6), length 55)
10.240.8.230.53839 > PUBLIC-IP.PORT: Flags [P.], cksum 0x7fb1 (correct), seq 12:15, ack 4, win 229, options [nop,nop,TS val 301278057 ecr 436763991], length 3
最佳答案
确保 iptables 没有阻止您的连接:
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
还要验证您在 tcpdump 中捕获了正确的接口(interface)
运行以下命令获取与 tcpdump 一起使用的接口(interface)列表:
# ip a|grep :|egrep -v 'link|inet'|awk '{print $2}'|sed 's/://'
lo
enp0s31f6
wlp2s0
所以你要尝试的 dcpdump 命令是(有线的):
# tcpdump -i enp0s31f6
或者(wifi):
# tcpdump -i wlp2s0
您的 Linux 上的接口(interface)名称可能不同。
关于linux - 几个数据包后 telnet/nc 无法发送数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54435050/