Linux command ($): traceroute command

Source: Internet
Author: User
Tags traceroute command

1. Command format:

traceroute[parameters [Host]

2. Command function:

The traceroute command allows you to track the routing path of a network packet, with a preset packet size of 40Bytes, which can be set separately by the user.

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 number of seconds;] [Host name or IP address] [Packet size]

3. Command parameters:

-D uses the socket-level troubleshooting feature.

-F Sets the size of the live value TTL for the first instrumented packet.

-F set do not leave the break.

-G Sets the source routing gateway, which can be set to a maximum of 8.

-I sends out the packet using the specified network interface.

-I replaces UDP data information with an ICMP response.

-M sets the size of the maximum surviving value TTL for the detection packet.

-N uses the IP address directly instead of the host name.

-P Sets the communication port for the UDP transport protocol.

-R ignores the normal routing Table and sends the packet directly to the remote host.

-S sets the IP address of the local host to send the packet.

-T sets the value of the TOS for the detection packet.

-V shows the execution of the instruction in detail.

-W Sets the time to wait for the remote host to return.

-X turns the correctness of the packet on or off.

4. Usage examples:

Example 1:traceroute usage simple, most common usage

Command:

Traceroute www.baidu.com

Output:

[Email protected] ~]# traceroute www.baidu.com
Traceroute to Www.baidu.com (61.135.169.125), hops max, + 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 * * *
[Email protected] ~]#

Description

Record by serial number starting from 1, each record is a hop, each hop represents a gateway, we see each line has three times, the unit is MS, is actually the default parameter-Q. The time the gateway responds after a probe packet sends three packets to each gateway, and if you use Traceroute-q 4 www.58.com, 4 packets are sent to each gateway.

Sometimes when we traceroute a host, we see that some of the rows are represented by asterisks. In this case, it is possible that the firewall has blocked the return information of ICMP, so we have not got any related packet return data.

Sometimes we have a long delay at a certain gateway, it is possible that a gateway is more blocked, or the physical device itself. Of course, if a DNS problem, can not resolve host name, domain name, there will be a long delay phenomenon; 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 the host problem or the gateway problem. If we encounter a problem through remote access to a server, we use the gateway that the Traceroute tracking packet, submitted to the IDC service provider, but also help to solve the problem, but at present, it seems difficult to solve such problems at home, that is, we found the problem, IDC service providers will not be able to help us solve.

Example 2: Hop count setting

Command:

Traceroute-m www.baidu.com

Output:

[Email protected] ~]# traceroute-m www.baidu.com
Traceroute to Www.baidu.com (61.135.169.105), hops max, + 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
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.1 48.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
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 * * *
[Email protected] ~]#

Example 3: show IP address, do not check host name

Command:

Traceroute-n www.baidu.com

Output:

[Email protected] ~]# traceroute-n www.baidu.com
Traceroute to Www.baidu.com (61.135.169.125), hops max, + byte packets
1 211.151.74.2 5.430 ms 5.636 ms 5.802 ms
2 211.151.56.57 0.627 ms 0.625 ms 0.617 ms
3 211.151.227.206 0.575 ms 0.584 ms 0.576 ms
4 210.77.139.145 0.703 ms 0.754 ms 0.806 ms
5 202.106.42.101 23.683 ms 23.869 ms 23.998 ms
6 202.106.228.37 247.101 MS * *
7 61.148.146.29 5.256 Ms 124.65.58.213 4.386 MS 4.373 ms
8 202.106.35.190 1.610 Ms 61.148.156.138 1.786 Ms 61.148.3.34 2.089 MS
9 * * *
30 * * *
[Email protected] ~]# traceroute www.baidu.com
Traceroute to Www.baidu.com (61.135.169.125), hops max, + byte packets
1 211.151.74.2 (211.151.74.2) 4.671 ms 4.865 ms 5.055 ms
2 211.151.56.57 (211.151.56.57) 0.619 ms 0.618 ms 0.612 ms
3 211.151.227.206 (211.151.227.206) 0.620 ms 0.642 ms 0.636 ms
4 210.77.139.145 (210.77.139.145) 0.720 ms 0.772 ms 0.816 ms
5 202.106.42.101 (202.106.42.101) 7.667 ms 7.910 ms 8.012 ms
6 bt-228-025.bta.net.cn (202.106.228.25) 2.965 Ms 2.440 Ms 61.148.154.97 (61.148.154.97) 431.337 ms
7 124.65.58.213 (124.65.58.213) 5.134 ms 5.124 ms 5.044 ms
8 202.106.35.190 (202.106.35.190) 1.917 ms 2.052 ms 2.059 ms
9 * * *
30 * * *
[Email protected] ~]#

Example 4: Basic UDP port settings used by probe packet 6888

Command:

Traceroute-p 6888 www.baidu.com

Output:

[Email protected] ~]# traceroute-p 6888 www.baidu.com
Traceroute to Www.baidu.com (220.181.111.147), hops max, + byte packets
1 211.151.74.2 (211.151.74.2) 4.927 ms 5.121 ms 5.298 ms
2 211.151.56.1 (211.151.56.1) 0.500 ms 0.499 ms 0.509 ms
3 211.151.224.90 (211.151.224.90) 0.637 ms 0.631 ms 0.641 ms
4 * * *
5 220.181.70.98 (220.181.70.98) 5.050 ms 5.313 ms 5.596 ms
6 220.181.17.94 (220.181.17.94) 1.665 MS! X * *
[Email protected] ~]#

Example 5: Set the number of probe packets to a value of 4

Command:

Traceroute-q 4 www.baidu.com

Output:

[Email protected] ~]# Traceroute-q 4 www.baidu.com
Traceroute to Www.baidu.com (61.135.169.125), hops max, + byte packets
1 211.151.74.2 (211.151.74.2) 40.633 ms 40.819 ms 41.004 ms 41.188 ms
2 211.151.56.57 (211.151.56.57) 0.637 ms 0.633 ms 0.627 ms 0.619 ms
3 211.151.227.206 (211.151.227.206) 0.505 ms 0.580 ms 0.571 ms 0.569 ms
4 210.77.139.145 (210.77.139.145) 0.753 ms 0.800 ms 0.853 ms 0.904 ms
5 202.106.42.101 (202.106.42.101) 7.449 ms 7.543 ms 7.738 ms 7.893 ms
6 61.148.154.97 (61.148.154.97) 316.817 Ms Bt-228-025.bta.net.cn (202.106.228.25) 3.695 ms 3.672 MS *
7 124.65.58.213 (124.65.58.213) 3.056 ms 2.993 ms 2.960 ms 61.148.146.29 (61.148.146.29) 2.837 ms
8 61.148.3.34 (61.148.3.34) 2.179 ms 2.295 ms 2.442 ms 202.106.35.190 (202.106.35.190) 7.136 ms
9 * * * *
30 * * * *
[Email protected] ~]#

Example 6: Bypass the normal routing table and send directly to a network-attached host

Command:

Traceroute-r www.baidu.com

Output:

[Email protected] ~]# traceroute-r www.baidu.com
Traceroute to Www.baidu.com (61.135.169.125), hops max, + byte packets
Connect: Network Unreachable
[Email protected] ~]#

Example 7: Setting the waiting response time for the external probe packet to 3 seconds

Command:

Traceroute-w 3 www.baidu.com

Output:

[Email protected] ~]# traceroute-w 3 www.baidu.com
Traceroute to Www.baidu.com (61.135.169.105), hops max, + byte packets
1 211.151.74.2 (211.151.74.2) 2.306 ms 2.469 ms 2.650 ms
2 211.151.56.1 (211.151.56.1) 0.621 ms 0.613 ms 0.603 ms
3 211.151.227.206 (211.151.227.206) 0.557 ms 0.560 ms 0.552 ms
4 210.77.139.145 (210.77.139.145) 0.708 ms 0.761 ms 0.817 ms
5 202.106.42.101 (202.106.42.101) 7.520 ms 7.774 ms 7.902 ms
6 bt-228-025.bta.net.cn (202.106.228.25) 2.890 Ms 2.369 Ms 61.148.154.97 (61.148.154.97) 471.961 ms
7 124.65.58.221 (124.65.58.221) 4.490 ms 4.483 ms 4.472 ms
8 123.126.6.198 (123.126.6.198) 2.948 Ms 61.148.156.6 (61.148.156.6) 7.688 Ms 7.756 ms
9 * * *
30 * * *
[Email protected] ~]#

Linux command ($): traceroute command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.