Por que o ping precisa ser reiniciado após a conexão ser restaurada

Por que o ping precisa ser reiniciado após a conexão ser restaurada

Meu laptop está executando o Fedora 25 (kernel 4.9.5) em uma conexão sem fio. Às vezes, minha linha xDSL cai e é restabelecida. Normalmente deixo o ping rodando e ele mostra isso:

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

O que é intrigante é que continua assim para sempre até eu reiniciar o 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

Parece que o ping está mantendo algum estado que precisa ser atualizado. O que poderia ser?

ATUALIZAR

... 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

Responder1

O problema provavelmente está no gateway, não no seu laptop. Mesmo que o ping falhe, você receberá uma resposta ICMP do gateway informando Destination Net Unreachable. É o gateway que não está mais tentando encaminhar seus pacotes de ping.

O gateway parece ser redefinido quando você reinicia o ping, sugerindo que de alguma forma ele está mantendo o estado com base no número de sequência nas suas solicitações de eco ICMP. Você pode evitar isso usando UDP para executar ping.

informação relacionada