为什么连接恢复后需要重新启动 ping

为什么连接恢复后需要重新启动 ping

我的笔记本电脑通过无线连接运行 Fedora 25(内核 4.9.5)。有时我的 xDSL 线路会断开并重新建立。我通常会让 ping 运行,它会显示以下内容:

64 bytes from 8.8.8.8: icmp_seq=294 ttl=48 time=79.0 ms
64 bytes from 8.8.8.8: icmp_seq=295 ttl=48 time=77.9 ms
From 192.168.5.1 icmp_seq=307 Destination Net Unreachable
From 192.168.5.1 icmp_seq=308 Destination Net Unreachable

令人费解的是,它会一直持续这样,直到我重新启动 ping:

From 192.168.5.1 icmp_seq=730 Destination Net Unreachable
From 192.168.5.1 icmp_seq=731 Destination Net Unreachable
From 192.168.5.1 icmp_seq=732 Destination Net Unreachable
^C
--- 8.8.8.8 ping statistics ---
10181 packets transmitted, 269 received, +154 errors, 97% packet loss, time 10414884ms
rtt min/avg/max/mdev = 76.417/84.643/271.002/20.913 ms
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=103 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=93.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=48 time=85.5 ms

ping 似乎正在保存一些需要刷新的状态。可能是什么?

更新

... xDSL is down
11:10:29.261358 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4160, seq 110, length 64
11:10:30.285354 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4160, seq 111, length 64
11:10:31.309315 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4160, seq 112, length 64
11:10:32.028919 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4382, seq 1, length 64

<<<<< ctrl-c ping, start ping again >>>>>

11:10:32.102610 IP 8.8.8.8 > 10.0.0.2: ICMP echo reply, id 4382, seq 1, length 64
11:10:33.030808 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4382, seq 2, length 64
11:10:33.113878 IP 8.8.8.8 > 10.0.0.2: ICMP echo reply, id 4382, seq 2, length 64
11:10:34.032032 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4382, seq 3, length 64
11:10:34.108532 IP 8.8.8.8 > 10.0.0.2: ICMP echo reply, id 4382, seq 3, length 64
11:10:35.033693 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4382, seq 4, length 64
11:10:35.111347 IP 8.8.8.8 > 10.0.0.2: ICMP echo reply, id 4382, seq 4, length 64
11:10:36.035507 IP 10.0.0.2 > 8.8.8.8: ICMP echo request, id 4382, seq 5, length 64
11:10:36.111723 IP 8.8.8.8 > 10.0.0.2: ICMP echo reply, id 4382, seq 5, length 64
^C

答案1

问题很可能出在网关上,而不是您的笔记本电脑上。即使 ping 失败,您也会收到网关发出的 ICMP 响应,提示“目标网络无法访问”。网关不再尝试转发您的 ping 数据包。

重新启动 ping 时,网关似乎会重置,这表明它以某种方式根据 ICMP 回显请求中的序列号保持状态。您可以使用 UDP 进行 ping 来避免这种情况。

相关内容