How to use traceroute command under Linux

  

In Linux system, traceroute command can be used to display the IP address of the router through which the packet passes, understand the walking path, the name is different in Linux system and windows system, not familiar with Linux system. The friend may not recognize it for a while, the following small series will give you a detailed introduction to the traceroute command.

By traceroute information we can know what path to go from your host computer to the other end of the Internet. Of course, each time a packet arrives at a certain destination by a certain starting point, the path may be different, but basically the route that is taken most of the time is the same

Linux system, we call it traceroute, tracert in MS Windows. Traceroute measures how long it takes by sending small packets to the destination device until it returns. Each device traceroute on a path is measured 3 times. The output includes the time (ms) of each test and the name of the device (if any) and its IP address.

In most cases, we will execute the command line directly under the Linux host system: traceroute hostname

and on Windows system is the command to execute tracert: tracert hostname

1. Command format:

traceroute[parameter][host]

2. Command function:

The traceroute command allows you to trace the routing path of network packets. Set the packet size to 40Bytes, which can be set by the user.

Specific parameter format: traceroute [-dFlnrvx][-f "survival value"] [-g "gateway". . .][-i "Web Interface"][-m "Survival Value"][-p"Communication Port"][-s"Source Address"[-t"Service Type"[-w"Timeout Seconds" ][Host Name or IP Address][Packet Size]

3. Command Parameters:

-d Use the Socket level troubleshooting function.

-f Sets the size of the TTL of the first detected packet's surviving value.

-F Set to leave the position.

-g Set the source routing gateway, up to 8 can be set.

-i Send packets using the specified web interface.

-I Use ICMP echo instead of UDP data information.

-m Sets the maximum TTL value of the detection packet.

-n Use IP addresses directly instead of host names.

-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 packet sent by the local host.

-t Set the TOS value of the detection packet.

-v Detailed display of the execution of the instruction.

-w Set the time to wait for the return of the remote host.

-x Turns packet integrity checking on or off.

4.Example of use:

Example 1: Traceroute Usage is simple and most commonly used

Command: traceroute www.baidu.com

Output:

The code is as follows:

[root@localhost ~]# traceroute www.baidu.com

traceroute to www.baidu.com (61.135.169.125), 30 hops max , 40 byte packets

1 192.168.74.2 (192.168.74.2) 2.606 ms 2.771 ms 2.950 ms

2 211.151.56.57 (211.151.56.57) 0.596 ms 0.598 ms 0.591 ms

3 211.151.227.206 (211.151.227.206) 0.546 ms 0.544 ms 0.538 ms

4 210.77.139.145 (210.77.139.145) 0.710 ms 0.748 ms 0.801 ms

5 202.106.42.101 (202.106 .42.101) 6.759 ms 6.945 ms 7.107 ms

6 61.148.154.97 (61.148.154.97) 718.908 ms * bt-228-025.bta.net.cn (202.106.228.25) 5.177 ms

7 124.65.58.213 (124.65.58.213) 4.343 ms 4.336 ms 4.367 ms

8 202.106.35.190 (202.106.35.190) 1.795 ms 61.148. 156.138 (61.148.156.138) 1.899 ms 1.951 ms

9 * * *

30 * * *

[root@localhost ~]#

:

The record starts from 1 by serial number. Each record is one hop. 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. The time that the probe packet returns after the gateway sends three packets to each gateway. If you use traceroute -q 4 www.58.com , it means to send 4 packets to each gateway.

Sometimes when we traceroute a host, we will see that some rows are represented by asterisks. In this case, it may be that the firewall has blocked the return information of ICMP, so we can't get any relevant data packet to return data.

Sometimes we have a long delay at a certain gateway. It may be because a gateway is blocked or it may be the physical device itself. Of course, if there is a problem with a DNS, the host name and domain name cannot be resolved, and there will be a long delay; you can add the -n parameter to avoid DNS resolution and output data in IP format.

If there are different network segments in the LAN, we can use traceroute to troubleshoot the problem, whether it is a host problem or a gateway problem. If we encounter problems by remotely accessing a server, we use traceroute to trace the gateway through which the packet passes, and submit it to the IDC service provider, which also helps solve the problem; but it seems difficult to solve such problems in China at present. The problem is that we find the problem, and the IDC service provider is not likely to help us solve it.

Example 2: Hop Count Settings

Command: traceroute -m 10 www.baidu.com

Output:

The code is as follows:

[root@localhost ~]# traceroute -m 10 www.baidu.com

traceroute to www.baidu.com (61.135.169.105), 10 hops max, 40 byte packets

1 192.168.74.2 (192.168.74.2) 1.534 ms 1.775 ms 1.961 ms

2 211.151.56.1 (211.151.56.1) 0.508 ms 0.514 ms 0.507 ms

3 211.151.227.206 (211.151.227.206 0.571 ms 0.558 ms 0.550 ms

4 210.77.139.145 (210.77.139.145) 0.708 ms 0.729 ms 0.785 ms

5 202.106.42.101 (202.106.42.101) 7.978 ms 8.155 ms 8.311 ms< Br>

6 bt-228-037.bta.net.cn (202.106.228.37) 772.460 ms bt-228-025.bta.net.cn (202.106.228.25) 2.152 ms 61.148.154.97 (61.148.154.97) 772.107 ms

7 124.65.58.221 (124.65.58.221) 4.875 ms 61.148.146.29 (61.148.146.29) 2.124 ms 124.65.58.221 (124.65.58.221) 4.854 ms< Br>

8 123.126.6.198 (123.126.6.198) 2.944 ms 61.148.156.6 (61.148.156.6) 3.505 ms 123.126.6.198 (123.126.6.198) 2.885 ms

9 * * *

10 * * *

[root@localhost ~]#
Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved