Traceroute uses ICMP and ttl,icmp for Echo information, including ip,ttl,sequence number, and so on. The TTL field is the initial set field of the sender, the RFC specifies a value of 64, for each router that processes the packet needs to reduce the value of TTL 1 or less time spent in the router, the general router forwarding packet delay of not more than 1s, so the TTL can be counted as the count of hops.
If the router receives an IP packet with a TTL value of 0 or 1, the router will not forward the packet, discarding the packet and sending the ICMP timeout information. The source address of the IP message containing the ICMP information is the IP address of the router. The traceroute can be used as a tool for tracing the gateway, as long as the setting is set to a reasonable TTL value. Send a datagram with a TTL value of 1, the first router will reduce the TTL value by 1, discard the datagram, and send the ICMP timeout information, get the IP of the first router, with the barber sent a TTL value of 2 of the datagram to get the address of the second router. Continue this process until the data is reported to the destination host, but even if the destination host receives an IP message with a TTL value of 1, it will not discard the datagram and send ICMP packets, because the datagram has reached the destination, how to determine whether the destination host has been reached? Send a copy of the UDP datagram to the destination host, where UDP uses a port number that is unreachable, based on whether the ICMP message is timed out or if the port is not up to the destination host.
The Linux system TTL value modification location is/proc/sys/net/ipv4/ip_default_ttl,
echo >/proc/sys/net/ipv4/ip_default_ttl
(This is transient) to set long-lasting can:
Modify the/etc/sysctl.conf configuration file and add the following line
net.ipv4.ip_default_ttl=128
The TTL in IP protocol is detailed