traceroute Command Cheatsheet

View Categories

traceroute Command Cheatsheet

3 min read

The traceroute command is a network diagnostic tool used to trace the path that a packet takes from your computer to a destination host. It provides details about each hop along the route, helping you identify network congestion, packet loss, and routing issues in large, complex networks.

Key Usage and Syntax of the traceroute Command #

The basic syntax of the traceroute command is:
traceroute [OPTIONS] <destination>

  • OPTIONS: Optional flags that can modify the behavior of the command.
  • destination: The target IP address or domain name of the host you want to trace.

Common traceroute Command Options #

  • -m <max_hops>: Specifies the maximum number of hops to be traced (default is 30).
  • -p <port>: Sends the trace to the specified port number (useful for TCP tracing).
  • -n: Disables name resolution (only shows IP addresses, not domain names).
  • -I: Uses ICMP ECHO (default is UDP datagrams).
  • -T: Uses TCP packets for tracing.
  • -w <timeout>: Sets the timeout for each reply.

traceroute Command Cheatsheet Table #

Command Description
traceroute <destination> Traces the route to a specified destination.
traceroute -m 20 <destination> Traces the route with a maximum of 20 hops.
traceroute -n <destination> Traces the route without performing DNS lookups (shows IPs only).
traceroute -p 80 <destination> Traces the route using port 80 (HTTP) for TCP packets.
traceroute -I <destination> Uses ICMP ECHO requests instead of UDP packets for tracing.
traceroute -T -p 443 <destination> Uses TCP packets on port 443 (HTTPS) for tracing.

How traceroute Works #

traceroute sends a series of packets with gradually increasing Time-to-Live (TTL) values. The TTL controls how many hops a packet can take before being discarded. Each router along the path decrements the TTL, and when it reaches 0, the router sends a time-exceeded message back to the source. This allows traceroute to record each hop’s IP address and response time.

Example Usage of the traceroute Command #

1. Basic Traceroute Command #

traceroute example.com
This traces the route from your machine to example.com, showing each hop and its response time.

2. Trace with a Specific Maximum Hop Count #

traceroute -m 15 example.com
Limits the trace to 15 hops before it stops, useful if you want to limit the traceroute for quicker results.

3. Trace Without DNS Lookups #

traceroute -n example.com
This skips the DNS lookup for each hop, so you only see the raw IP addresses of the routers involved.

4. Trace Using ICMP ECHO Requests (for ICMP-based networks) #

traceroute -I example.com
This sends ICMP ECHO requests instead of the default UDP packets. This can be useful when working with ICMP-based routing setups.

5. Trace Using TCP Packets (for firewall-friendly tracing) #

traceroute -T -p 80 example.com
This uses TCP packets instead of UDP, which can be helpful for tracing through firewalls that block UDP packets but allow TCP traffic.

6. Trace with a Specific Port (Useful for Diagnosing Web Services) #

traceroute -p 443 example.com
This traces the route using TCP packets on port 443, useful for diagnosing issues with HTTPS traffic.

Example Output of traceroute #

traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 1.101 ms 1.058 ms 1.049 ms
2 10.10.10.1 (10.10.10.1) 10.491 ms 10.429 ms 10.395 ms
3 172.16.1.1 (172.16.1.1) 20.410 ms 20.355 ms 20.314 ms
4 203.0.113.1 (203.0.113.1) 30.761 ms 30.735 ms 30.700 ms
5 example.com (93.184.216.34) 40.812 ms 40.795 ms 40.771 ms

Explanation of Output:

  • Hop #: The sequence number for each hop.
  • IP Address: The IP address of the router or destination at each hop.
  • Response Time: The round-trip time for the packet to reach the hop and return. The times are in milliseconds (ms).
  • TTL: The Time to Live, indicating how many hops the packet can make before being discarded.

Advanced Uses of traceroute #

Traceroute with DNS Resolution Disabled #

traceroute -n google.com
This shows only IP addresses without attempting to resolve hostnames, which is useful for performance testing or when DNS resolution is unreliable.

Trace Using TCP Packets for Better Firewall Traversal #

traceroute -T -p 80 google.com
Using TCP packets is often more reliable through firewalls, as some firewalls may block UDP packets, which traceroute uses by default.

Trace a Specific Path for Diagnosing Web Servers #

traceroute -p 443 google.com
This is particularly helpful when diagnosing web server connectivity, as it targets the HTTPS port.

Using traceroute for RELIANOID Load Balancer #

In a RELIANOID load balancer environment, traceroute can help identify network bottlenecks and diagnose issues with backend server communication. Here’s how you can use it effectively:

1. Diagnosing Network Latency #

traceroute loadbalancer.relianoid.com
Use traceroute to check if there are delays or latency issues along the route from the client to the load balancer or between the load balancer and backend servers.

2. Verifying Backend Communication Paths #

traceroute backend-server1.relianoid.com
Ensure that traffic between the load balancer and backend servers is routed properly.

3. Troubleshooting Firewall and Network Restrictions #

traceroute -T -p 443 backend-server2.relianoid.com
Use traceroute with TCP or specific ports (e.g., port 443 for HTTPS) to test through firewalls.

Summary #

The traceroute command is an essential tool for diagnosing network connectivity and routing issues by mapping the path that packets take from the source to the destination. It can be used to monitor network performance, identify latency or bottlenecks, and troubleshoot routing problems, especially in complex environments like load balancers.

SHARE ON:

Powered by BetterDocs