☼
⌃
☰

traceroute

Table of Contents

Traceroute


Description

Traceroute (known as tracert on Windows systems) is a fundamental network utility whose primary purpose is to determine the exact sequence of routers (or hops) that a data packet takes from the source computer to a specified destination host. It is an active reconnaissance tool because it involves sending packets directly to the target network.

How it Works

Traceroute works by exploiting a specific field in the IP header called the Time-To-Live (TTL).

  1. Sending Probes: The source computer sends a sequence of three or more packets (either UDP packets on Unix-like systems or ICMP Echo Request packets on Windows).
  2. Incrementing TTL: The first set of packets is sent with a TTL of 1.
  3. Router Response (Hop 1): The first router it encounters decrements the TTL to 0. Since a TTL of 0 means the packet must be discarded, the router sends back an ICMP Time Exceeded message to the source, revealing its IP address. This is the first "hop."
  4. Next Hop: The next set of packets is sent with a TTL of 2. This time, the first router passes it, the second router decrements the TTL to 0, discards it, and sends the ICMP Time Exceeded message, revealing the second router's IP address.
  5. Reaching Destination: This process continues, incrementing the TTL by 1 for each sequence, until the packets finally reach the destination. The destination host responds with an ICMP Port Unreachable (for UDP probes) or ICMP Echo Reply (for ICMP probes), indicating the end of the path.
  6. Output: The command displays the router's IP address and the round-trip time (RTT) for each of the three packets at every hop.

This reveals the entire path and helps diagnose where network latency or routing problems might be occurring.


Examples

The command syntax varies slightly between operating systems, but the function is the same.

Command-Line Usage

OS Command Output Description
Linux/macOS traceroute google.com IP addresses and milliseconds per hop. Uses UDP packets by default.
Windows tracert google.com IP addresses and milliseconds per hop. Uses ICMP packets by default.

Example Output (Linux/macOS)

```bash $ traceroute google.com

traceroute to google.com (142.250.75.14), 64 hops max, 52 byte packets 1 router (192.168.1.1) 1.213 ms 0.781 ms 0.893 ms 2 24.123.45.67 (24.123.45.67) 9.502 ms 9.611 ms 10.123 ms 3 * * * 4 72.14.239.195 (72.14.239.195) 25.321 ms 25.567 ms 25.401 ms 5 142.250.75.14 (142.250.75.14) 26.115 ms 26.299 ms 26.540 ms