SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
SurferCloud Blog SurferCloud Blog
SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
  • banner shape
  • banner shape
  • banner shape
  • banner shape
  • plus icon
  • plus icon

How to Use the Traceroute Command in Linux: A Beginner's Guide

December 18, 2024
5 minutes
TUTORIAL
323 Views

When diagnosing network connectivity issues, the traceroute command is a crucial tool for tracking the path packets take from your device to a destination server. It reveals the route and the time taken at each hop, making it easier to detect delays, routing issues, or dropped connections.

This guide will explain how to use the traceroute command, its key options, and how SurferCloud can help you maintain stable network connectivity with its fast, secure cloud services.


What is Traceroute?

Traceroute is a command-line tool that tracks the route that packets take from a source device to a specified destination (like a website or an IP address). It provides a list of each “hop” or intermediary device the packet passes through, along with the time taken at each step.

This tool is essential for network diagnostics, as it reveals potential issues like:

  • Packet Loss: Identify where packets are being dropped.
  • Network Delays: Detect where network slowdowns occur.
  • Routing Loops: Find loops in the routing path.

How Does Traceroute Work?

Traceroute sends a series of packets with incrementally increasing Time-to-Live (TTL) values. Each hop (or router) along the route decreases the TTL by 1. When the TTL reaches 0, the router returns an error message (ICMP Time Exceeded) to the sender.

For example:

  1. The first packet has a TTL of 1 and only reaches the first router.
  2. The second packet has a TTL of 2, so it reaches the second router before being dropped.
  3. This process continues until the packet reaches the final destination.

By recording the IP address of each router and the time it takes to respond, traceroute builds a "map" of the route.


How to Use the Traceroute Command in Linux

To use traceroute, you need to have it installed. It is usually pre-installed on most Linux distributions, but if it's not, you can install it as follows:

Install Traceroute on Linux:

sudo apt-get install traceroute   # Debian/Ubuntu
sudo yum install traceroute       # CentOS/RHEL

Basic Traceroute Command

The simplest way to use traceroute is as follows:

traceroute example.com

Explanation:

  • traceroute: The command to trace the route.
  • example.com: The destination URL or IP address you want to trace.

Example Output:

traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  1.234 ms  1.223 ms  1.189 ms
 2  10.0.0.1 (10.0.0.1)  2.123 ms  2.231 ms  2.194 ms
 3  203.0.113.1 (203.0.113.1)  12.456 ms  12.334 ms  12.567 ms
 4  93.184.216.34 (93.184.216.34)  25.678 ms  25.899 ms  25.432 ms

How to Read the Output:

  • Hop Number: The first column indicates the hop count.
  • IP Address: The IP address or hostname of each router.
  • Response Times: The time (in milliseconds) it takes for packets to reach each hop (3 attempts are shown).

Traceroute Command Options

You can customize traceroute with various options to get more precise information.

OptionDescriptionExample
-nAvoid DNS lookups to display IP addresses only.traceroute -n example.com
-wSets the timeout for response time (in seconds).traceroute -w 3 example.com
-qNumber of queries (probes) to send per hop.traceroute -q 5 example.com
-mMaximum number of hops (default is 30).traceroute -m 20 example.com
-IUse ICMP ECHO instead of UDP probes.traceroute -I example.com

Examples of Traceroute Commands

Here are some practical examples of how you can use traceroute for network diagnostics.

1. Trace route without DNS lookup

Use the -n option to speed up traceroute by skipping DNS lookups.

traceroute -n example.com

2. Increase maximum hops to 50

By default, traceroute stops after 30 hops. Use -m to increase this limit.

traceroute -m 50 example.com

3. Set timeout to 5 seconds

If some hops are slow, you can increase the response wait time from 3 to 5 seconds.

traceroute -w 5 example.com

4. Trace using ICMP (like Windows tracert)

On Windows, the tracert command uses ICMP packets instead of UDP. To replicate this behavior in Linux, use the -I option.

traceroute -I example.com

Common Issues with Traceroute

While traceroute is useful, it has some limitations:

  1. Firewalls May Block Traceroute
    Firewalls sometimes block the UDP or ICMP packets used by traceroute, resulting in "Request Timed Out" messages.
  2. Anonymous Hops (Unknown Hops)
    If traceroute encounters a private IP address (like 10.x.x.x) or an ISP router, it may not display the hostname or IP.
  3. High Latency
    If a hop displays unusually high response times, it may be a sign of network congestion or an overloaded router.

How to Troubleshoot Using Traceroute

If your website is slow, a traceroute can help identify the problem:

  • Look for hops with large response times — this indicates network congestion.
  • If multiple hops are timing out (***), it may mean a router is down or blocking ICMP.
  • If you see the same IP repeated in multiple hops, you might have a routing loop.

How SurferCloud Helps with Connectivity

SurferCloud provides a robust global infrastructure with over 16 data centers worldwide, reducing latency and improving network stability. Here’s how SurferCloud supports network diagnostics and stability:

  • Global Reach: Access data centers across the US, Europe, Asia, and more.
  • Faster Connections: Reduce the number of hops with low-latency network paths.
  • DDoS Protection: SurferCloud offers advanced DDoS protection, ensuring your server remains online even during attacks.
  • 24/7 Support: If you're facing routing issues, SurferCloud's support team is always ready to assist.

Conclusion

The traceroute command is essential for diagnosing network issues, identifying slow hops, and tracing the path packets take. With options like -n, -w, and -I, you can customize traceroute to suit your troubleshooting needs.

If you’re looking for a cloud provider that ensures fast, stable, and secure network connections, SurferCloud is your best choice. Its extensive data center network and powerful DDoS protection guarantee smooth performance for websites, applications, and cloud services.

Tags : check packet route how to use traceroute linux network diagnostics Linux VPS hosting network path analysis SurferCloud VPS trace ip route traceroute command options traceroute linux troubleshoot network issues

Related Post

4 minutes TUTORIAL

How to Use the ps aux Command in Linux

The ps aux command in Linux is an essential tool for mo...

4 minutes TUTORIAL

Why Is Your Website Slow? Common Causes and S

A slow website can frustrate visitors, hurt search engi...

1 minute TUTORIAL

How to Top up Your SurferCloud Account Balanc

How to top up your SurferCloud account balance? Some us...

Affordable CDN

ucdn

2025 Special Offers:

annual vps

Light Server promotion:

ulhost-promo

Cloud Server promotion:

cloud server

Copyright © 2024 SurferCloud All Rights Reserved.  Sitemap.