About the route trace command ---traceroute

We have all used the ping command to check whether the host and the target address are connected, and the communication rate of the communication packets between the host and the target address. The so-called communication packets are those TCP/IP, UDP packets.

About traceroute:
The traceroute instruction is traceroute for Linux, and tracert for Windows. This time, it is mainly traceroute.
traceroute is a tool used to detect the number of gateways passed between the originating host and the destination host. The principle of traceroute is to try to send out a probe packet with the smallest TTL (time to live) to track the gateway through which the data packet reaches the target host, and then listen for a response from the gateway ICMP. The size of the send packet defaults to 38 bytes.

The complete process of the traceroute program: first, it sends an IP packet with a TTL field of 1 to the destination host, the first router that processes this packet decrements the TTL value by 1, then discards the datagram and sends an ICMP to the source host packet ("timeout" message, this packet contains the IP address of the router, thus getting the address of the first router), then traceroute sends a datagram with a TTL of 2 to get the IP address of the second router, Continue this process until the datagram reaches the destination host.

1. Command format:

traceroute [parameter] [host]

2. Command function: The
traceroute command allows you to trace the routing of network data packets. The default data packet size is 40Bytes, and the user can set it separately.

**Specific parameter format:**traceroute [-dFlnrvx][-f<survival value>][-g<gateway>…][-i<network interface>][-m<survival value>][-p<communication port>][-s<source address>][-t<service type>][-w<timeout seconds>][hostname or IP address][packet size]

3. Command parameters:

-d Use socket-level debugging.
-f Set the size of the first detection packet's keepalive value TTL.
-F Set the do not leave bit.
-g Set source routing gateway, up to 8 can be set.
-i Send out packets using the specified network interface.
-I Use ICMP responses instead of UDP data messages.
-m Set the size of the maximum survival value TTL of the detection packet.
-n Use the IP address directly instead of the hostname.
-p Set the communication port of the UDP transport protocol.
-r Ignore the normal Routing Table and send the packet directly to the remote host.
-s Set the IP address of the outgoing packet from the local host.
-t Set the TOS value of the detection packet.
-v Displays the execution process of the command in detail.
-w Sets the time to wait for the remote host to report back.
-x Enables or disables correctness checking of packets.
4 Examples:
Example 4.1
: traceroute www.baidu.com

Description:
The records start from 1 according to the serial number. Each record is a hop, and each hop represents a gateway. We see that each line has three times, the unit is ms, which is actually the default parameter of -q. After the probe packet sends three packets to each gateway, the gateway returns the response time; if you use traceroute -q 4 www.baidu.com, it means that 4 packets are sent to each gateway. See below:

Sometimes when we traceroute a host, we see some lines represented by asterisks. In such a situation, it may be that the firewall has blocked the return information of ICMP, so we can't get any relevant packet return data.

Sometimes we have a long delay at a certain gateway. It may be that a certain gateway is blocked, or it may be the reason of the physical device itself. Of course, if there is a problem with a certain DNS, when the host name and domain name cannot be resolved, there will also be a long delay; you can add the -n parameter to avoid DNS resolution and output data in IP format.
If it is between different network segments in the LAN, we can use traceroute to troubleshoot the problem, whether it is the host or the gateway. If we encounter a problem when accessing a server remotely, we use traceroute to track the gateway that the data packet passes through and submit it to the IDC service provider, which can also help solve the problem; but it seems that it is difficult to solve such a problem in China at present. Yes, that is, we found the problem, and the IDC service provider could not help us solve it.

Example 4.2: Hop count setting
Command: traceroute -m 10 www.baidu.com

Description: Through the result, you can see that the survival value = 10, when the survival value = 0, the host will cancel the data packet

Example 3: The basic UDP port used by the probe packet is set to 6888 (I don't understand it here)
Command: traceroute -p 6888 www.baidu.com

Example 4: Set the waiting response time for outgoing probe packets to 3 seconds
Command: traceroute -w 3 www.baidu.com

おすすめ

転載: blog.csdn.net/weixin_43214644/article/details/126419796