How to Install and Use tcptraceroute in Linux to Trace Network Paths Through Firewalls

Standard network troubleshooting tools such as classic traceroute and ping rely on ICMP Echo Request packets or high-numbered UDP probes to chart router hops across the internet. However, modern corporate firewalls, cloud security groups, and enterprise border gateways routinely block ICMP traffic and unassigned UDP ports by default. Consequently, traditional traceroutes frequently terminate in rows of uninformative asterisks (* * *), obscuring where packet loss occurs. tcptraceroute overcomes this limitation by transmitting TCP SYN packets directed at standard service ports (such as 80 or 443), allowing administrators to trace paths through perimeter packet filters.

The Technical Principle: Why TCP Probes Bypass Filters

Standard packet filters and stateful firewalls are specifically configured to permit inbound and outbound connections to legitimate web and application services. Because tcptraceroute crafts TCP SYN packets identical to initial connection handshake requests, firewalls permit the probes through their filtering tables.

  • Hop Discovery: tcptraceroute increments the IP header’s Time-To-Live (TTL) field starting from 1.
  • Intermediate Hops: Each intermediary router decrements the TTL. When the TTL reaches 0, the router discards the packet and transmits back an ICMP Time Exceeded message, revealing its IP address.
  • Destination Response: When the probe reaches the target server, if the port is open, the host responds with a standard TCP SYN/ACK packet (or a TCP RST if the port is closed), establishing that the full network route is intact.

Installing tcptraceroute on Major Linux Distributions

tcptraceroute is available natively across all standard enterprise and community Linux package repositories:

Distribution / Platform Package Manager Installation Command
Ubuntu / Debian / Mint sudo apt update && sudo apt install tcptraceroute
Arch Linux / Manjaro sudo pacman -S tcptraceroute
Fedora / RHEL / AlmaLinux sudo dnf install tcptraceroute
openSUSE sudo zypper install tcptraceroute

Basic Usage and Target Port Specification

Because crafting raw TCP packets requires elevated socket access, tcptraceroute must be run with administrative privileges or granted packet capture capabilities via setcap.

By default, tcptraceroute targets TCP port 80 (standard HTTP). To execute a basic trace against a remote web server:

sudo tcptraceroute example.com

If you are diagnosing an encrypted web service or an API gateway running on HTTPS, explicitly declare destination port 443:

sudo tcptraceroute example.com 443

The command traces through intermediate hops and outputs the millisecond response latency for each step. Upon reaching the destination, the terminal outputs [open] to indicate a successful SYN/ACK receipt.

Essential Command Flags and Troubleshooting Options

To customise trace behaviour and diagnose complex network anomalies, combine these standard parameters:

  • -s <IP>: Sets the source IP address if your host possesses multiple network interfaces.
  • -i <interface>: Forces packet transmission over a specific interface (e.g. -i eth1 or -i tun0 for VPN tunnels).
  • -m <hops>: Sets the maximum TTL threshold (defaults to 30 hops).
  • -q <queries>: Sets the number of probe packets per hop (defaults to 3).
  • -w <seconds>: Defines the probe timeout duration in seconds before logging an asterisk.
  • -n: Disables DNS reverse lookups to speed up terminal rendering.

For example, to quickly trace a path to a remote SSH server on port 22 without resolving reverse hostnames:

sudo tcptraceroute -n -m 20 example.com 22

Granting Non-Root Execution Permissions

If developers or operational staff require access to tcptraceroute without full sudo administrative rights, assign raw network packet capabilities using Linux setcap:

sudo setcap cap_net_raw+ep $(which tcptraceroute)

Users can now execute tcptraceroute example.com directly from unprivileged shell sessions, simplifying daily monitoring and diagnostics.

Employing tcptraceroute allows network engineers and systems administrators to cut through deceptive firewall drops, pinpointing exactly where transit packets stall across complex modern networks.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.