為什麼連線恢復後需要重新啟動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 來避免這種情況。

相關內容