One Linux command per day (--traceroute) command

Source: Internet
Author: User
Tags traceroute command

By traceroute we can know what path the information from your computer to the other end of the Internet host is walking. Of course, each time a packet arrives at a similar destination (destination) by a similar starting point (source), the path may be different, but basically the route is the same. A Linux system, which we call Tracertoute, is tracert in MS Windows. Traceroute measures how long it takes to send a small packet to the destination device until it returns. Each device on a path is measured 3 times traceroute. The output includes the time of each test (MS) and the name of the device and its IP address.

In most cases, we will execute the command line directly under the Linux host system.

traceroute hostname

Under Windows, the command to execute tracert is:

tracert hostname

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 Bytes, 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 using the socket-level troubleshooting function

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

-F settings do not leave the Duan----I do not know what is not to leave the Duan, checked the next did not find what information ^ ^

-G Set source routing gateway with up to 8

-I send out packets using the specified network interface

-I replaces UDP data information with ICMP response

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

-N Direct use of IP addresses instead of host names

-P Set the communication port of the UDP transport protocol

-R ignores normal routing table and sends packets 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 verbose display of instruction execution process

-W Set the time to wait for the remote host to return

-X Correctness check of the data packet on or off

4. Usage examples:

Example 1:traceroute usage is simple, the most common usage

Command: Traceroute www.google.com

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 that the gateway responds after a probe packet sends three packets to each gateway, or if you use Traceroute-q 4 www.google.com, to send 4 packets 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 packets to return the data.

Sometimes we have a long delay in a gateway, it is possible that a gateway is blocked, or the physical device itself, of course, if a DNS problem, can not resolve the host name, domain name, there will be a delay long 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, that is, we find the problem lies, IDC service providers will not be able to help us solve.

Example 2: Hop count setting

Command:

Traceroute-m www.baidu.com

Example 3: Show only IP addresses, not hostname DNS

Command: Traceroute-n www.baidu.com

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

Command: Traceroute-p 6888 www.baidu.com

Example 5: Set the number of probe packets to 4

Command: Traceroute-q 4 www.baidu.com

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

Command: Traceroute-r www.baidu.com

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

Command: Traceroute-w 3 www.baidu.com

>>>>>>>> explain how Traceroute works >>>>>>>>>>>>>>

The Traceroute program is designed to utilize the TTL (Time to live) field (field) of the ICMP and IP header. First, Traceroute sends out a TTL of 1 IP datagram (3 40-byte packets each, including the source address, destination address, and packet-issued time label) to the destination, when the first router on the path (router) receives the datagram, It reduces the TTL by 1, at this point, the TTL becomes 0, so the path will be dropped to the secondary datagram, and send back an "ICMP Time Exceeded" message, Traceroute received this message, they know that the router exists on this path, The traceroute then sends another datagram with a TTL of 2, discovers the second router, and repeats the operation until a datagram arrives at the destination.

When the traceroute sends the UDP datagram to the destination, the port number it chooses to deliver is the one that the general application will not use, so when the UDP datagram arrives at the destination, the host sends back an ICMP port Unreachab Le, and when traceroute receives the message, it knows that the destination has arrived, so traceroute does not have the so-called daemon program on the server side.

Traceroute computes the IP address of the ICMP TTL expiration message device and makes the domain name resolution. Each time, traceroute prints out a series of data, including the domain name and IP address of the routed device that was passed, and the time it takes each three packets to go back and forth.

>>>>>>>>>>>>>>>

Tracert under Windows, the principle and effect are the same. This is not detailed in detail here.

One Linux command per day (--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.