TTL в пинг против копать
Когда я побежал ping google.com
Я получаю ttl
ценность 55
:
64 bytes from 173.194.127.103: icmp_seq=68 ttl=55 time=16.4 ms
Когда я побежал dig google.com @ns1.google.com.
, это получить TTL
ценность 300
,
google.com. 300 IN A 173.194.127.34
Почему я получаю два разных значения для TTL
и какой из них актуален в какой ситуации?
2 ответа
TTL
с ping
имеет совершенно другое значение, чем для DNS.
Для DNS это означает, как долго может кэшироваться запись, прежде чем она будет считаться слишком старой. Значение для ping
означает, сколько прыжков пакет может пройти через разные сети, прежде чем он будет отброшен. Каждый переход по пути к цели будет уменьшать это значение на 1, и если будет слишком много переходов, пакет будет отброшен. Это предназначено для предотвращения бесконечных циклов для пакетов в случае ошибок конфигурации.
И я согласен, что бегемот, такой как Google, который должен идти на все, и использовать каждую доступную уловку, чтобы иметь возможность ответить так же быстро, как и он, не является хорошим примером для рассмотрения этого вопроса.
Дополнительный контекст по ping TTL с manpage.
TTL DETAILS
The TTL value of an IP packet represents the maximum number of IP
routers that the packet can go through before being thrown away. In
current practice you can expect each router in the Internet to decre-
ment the TTL field by exactly one.
The TCP/IP specification states that the TTL field for TCP packets
should be set to 60, but many systems use smaller values (4.3 BSD uses
30, 4.2 used 15).
The maximum possible value of this field is 255, and most Unix systems
set the TTL field of ICMP ECHO_REQUEST packets to 255. This is why you
will find you can ‘‘ping’’ some hosts, but not reach them with tel-
net(1) or ftp(1).
In normal operation ping prints the ttl value from the packet it
receives. When a remote system receives a ping packet, it can do one
of three things with the TTL field in its response:
· Not change it; this is what Berkeley Unix systems did before the
4.3BSD Tahoe release. In this case the TTL value in the received
packet will be 255 minus the number of routers in the round-trip
path.
· Set it to 255; this is what current Berkeley Unix systems do. In
this case the TTL value in the received packet will be 255 minus the
number of routers in the path from the remote system to the pinging
host.
· Set it to some other value. Some machines use the same value for ICMP
packets that they use for TCP packets, for example either 30 or 60.
Others may use completely wild values.