当我运行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.34TTL有两个不同的值,哪个值与什么情况有关?发布于 2015-01-21 14:08:19
与DNS相比,带有TTL的ping具有完全不同的含义。
对于DNS来说,它意味着记录在被认为太旧之前可以缓存多长时间。ping的值意味着数据包在被丢弃之前可以接管不同网络的跳数。在到达目标的路径上,每跳一次就会将该值减少1,如果跳数过多,数据包将被丢弃。这是为了防止在配置错误的情况下对数据包进行永不结束的循环。
我也同意,像谷歌这样的庞然大物,必须千方百计地运用每一个技巧来尽快回答这个问题,这并不是一个好的例子。
发布于 2015-01-22 04:14:08
来自手册的ping TTL的附加上下文。
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.https://serverfault.com/questions/661226
复制相似问题