Operations 5 min read

Master traceroute on Linux: Install, Commands, and Advanced Options

This guide explains what traceroute does, how to install it on various Linux distributions, and provides detailed command syntax, common and advanced options, practical examples, and important precautions for effective network troubleshooting.

Raymond Ops
Raymond Ops
Raymond Ops
Master traceroute on Linux: Install, Commands, and Advanced Options

In Linux,

traceroute

is a network diagnostic tool that shows the route packets take to a target host.

If it is not installed, you can add it using the system package manager.

Debian/Ubuntu and derivatives

<code>sudo apt-get update
sudo apt-get install traceroute</code>

CentOS/RHEL and derivatives

<code>sudo yum install traceroute</code>

On newer CentOS/RHEL versions you may need to use

dnf

instead of

yum

:

<code>sudo dnf install traceroute</code>

Basic command format

<code>traceroute [options]... [target host]</code>

Basic usage example

Trace the route to

example.com

:

<code>traceroute example.com</code>

Common options

-n

: Do not perform DNS lookups, show IP addresses only.

-w

: Set timeout in seconds.

-p

: Specify port number (default 33434).

-m

: Set maximum hop count (default 30).

-s

: Set source port number.

-I

: Use ICMP packets.

-4

or

-6

: Force IPv4 or IPv6.

-q

: Set number of probe packets (default 3).

-T

: Use TCP for tracing.

-A

: Use all protocols (UDP, TCP, ICMP).

Advanced options

-P proto

: Choose protocol (tcp, udp, icmp, ip).

-S srcaddr

: Set source address.

-g gateway

: Specify a gateway to skip.

-N

: Use NTP mode for time queries.

-F

: Set “Don’t Fragment” flag to determine MTU.

Examples

Do not resolve DNS, show IPs only:

<code>traceroute -n example.com</code>

Use ICMP protocol:

<code>traceroute -I example.com</code>

Set maximum hops to 20:

<code>traceroute -m 20 example.com</code>

Use TCP protocol:

<code>traceroute -T example.com</code>

Use all protocols:

<code>traceroute -A example.com</code>

Send 5 probe packets:

<code>traceroute -q 5 example.com</code>

Set timeout to 10 seconds:

<code>traceroute -w 10 example.com</code>

Precautions

Some network devices may block traceroute packets, resulting in incomplete or inaccurate path information.

Use traceroute in compliance with network policies and legal regulations.

Root privileges may be required on certain Linux distributions.

traceroute

is an essential tool for network troubleshooting and performance analysis, helping locate latency or packet loss.

Network TroubleshootingtracerouteLinuxcommand-linenetwork diagnostics
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.