Traceroute

Traceroute

One-liner: A network diagnostic tool that maps the path packets take to reach a destination by exploiting TTL (Time To Live) expiration.

🎯 What Is It?

Traceroute is a network diagnostic utility that reveals every router (hop) between your system and a destination. It works by sending packets with incrementally increasing TTL values, causing each router along the path to respond with an ICMP Time Exceeded message.

On Windows, the command is tracert; on Linux/macOS, it's traceroute.

πŸ€” Why It Matters

πŸ”¬ How It Works

Core Principles

  1. Send packet with TTL=1 β†’ First router decrements to 0 β†’ Sends ICMP Time Exceeded
  2. Send packet with TTL=2 β†’ Second router decrements to 0 β†’ Sends ICMP Time Exceeded
  3. Continue incrementing TTL until destination is reached
  4. Record IP addresses and response times for each hop

Visual Flow

TTL=1 ──► [Router 1] ──► ICMP Time Exceeded (reveals Router 1 IP)
TTL=2 ──► [Router 1] ──► [Router 2] ──► ICMP Time Exceeded (reveals Router 2 IP)
TTL=3 ──► [Router 1] ──► [Router 2] ──► [Target] ──► ICMP Echo Reply

Technical Deep-Dive

# Linux: Basic traceroute
traceroute tryhackme.com

# Windows: Basic tracert
tracert tryhackme.com

# Linux: Use ICMP instead of UDP (like Windows)
traceroute -I tryhackme.com

# Linux: Use TCP SYN (bypass ICMP filtering)
sudo traceroute -T -p 443 tryhackme.com

# Linux: Set max hops
traceroute -m 20 tryhackme.com

πŸ“Š Platform Differences

Aspect Linux traceroute Windows tracert
Default Protocol UDP ICMP
Packets per Hop 3 3
Max Hops 30 30
Requires Root For ICMP/TCP modes No

πŸ“Š Reading Output

 1  router1.isp.com (192.168.1.1)    1.234 ms  1.456 ms  1.123 ms
 2  * * *
 3  core.isp.com (10.0.0.1)          15.678 ms 14.234 ms 16.789 ms
Symbol Meaning
IP/hostname Router responded
* No response (timeout, filtered, or router doesn't reply)
!H Host unreachable
!N Network unreachable
!P Protocol unreachable

πŸ›‘οΈ Detection & Prevention

How to Detect

How to Prevent / Mitigate

🎀 Interview Angles

Common Questions

STAR Story

Situation: Client reported intermittent connectivity to cloud services.
Task: Identify where packet loss was occurring.
Action: Ran traceroute during issue windows, identified consistent packet loss at hop 7 (ISP border router). Correlated with ISP maintenance windows.
Result: Documented evidence for ISP escalation; issue resolved after ISP fixed misconfigured router.

βœ… Best Practices

❌ Common Misconceptions

πŸ“š References