Traceroute command reference
Complete reference for traceroute flags and options on Linux, macOS, and Windows, including probe protocols, TTL limits, and output formatting.
Complete reference for traceroute and tracert command-line flags and options on Linux, macOS, and Windows.
Traceroute Syntax on Linux and macOS
Traceroute on Linux and macOS follows this general syntax:
traceroute [options] host [packet_size]The
host argument accepts a hostname or an IP address in dotted-decimal notation (e.g., 203.0.113.1). The optional
packet_size argument sets the probe packet size in bytes (default: 60 bytes for IPv4, 80 bytes for IPv6).
Traceroute Options on Linux and macOS
Traceroute on Linux and macOS accepts the following command-line flags. Options that change the probe protocol (such as
-I and
-T) require root or sudo privileges.
| Flag | Description | Default | Example |
|---|---|---|---|
-n | Display numeric IP addresses only. Traceroute skips reverse DNS lookups, which speeds up the output | Resolve hostnames | traceroute -n example.com |
-m max_ttl | Set the maximum Time to Live (TTL) value for outgoing probes. Traceroute stops after this many hops. Range: 1--255 | 30 | traceroute -m 20 example.com |
-w wait_time | Set the timeout in seconds for each probe response. Traceroute prints an asterisk (
*) if no response arrives within this period | 5 | traceroute -w 3 example.com |
-q nqueries | Set the number of probe packets traceroute sends per TTL value. Range: 1--1000 | 3 | traceroute -q 1 example.com |
-p port | Set the base UDP destination port number. Traceroute increments this port for each probe. Range: 1--65535 | 33434 | traceroute -p 44434 example.com |
-i initial_ttl | Set the initial TTL value for the first set of probes. Traceroute skips hops below this value | 1 | traceroute -i 5 example.com |
-t tos | Set the Type of Service (ToS) field in the IP header of outgoing probes. Range: 0--255 | 0 | traceroute -t 16 example.com |
-I | Use ICMP Echo Request probes instead of the default UDP probes. Requires root privileges. ICMP probes often pass through firewalls that block UDP | UDP | sudo traceroute -I example.com |
-T | Use TCP SYN probes instead of UDP. Requires root privileges. TCP probes target port 80 by default and can bypass firewalls that allow HTTP traffic | UDP | sudo traceroute -T example.com |
-4 | Force traceroute to use IPv4 transport | Auto-detect | traceroute -4 example.com |
-6 | Force traceroute to use IPv6 transport | Auto-detect | traceroute -6 example.com |
-s src_addr | Set the source IP address for outgoing probes. The address must belong to a local interface | Default interface | traceroute -s 192.168.1.10 example.com |
Tracert Syntax on Windows
Windows uses the
tracert command. The syntax is:
tracert [options] target_nameThe
target_name argument accepts a hostname or IP address.
Tracert Options on Windows
Windows
tracert accepts the following flags. Run Command Prompt as Administrator for full functionality.
| Flag | Description | Default | Example |
|---|---|---|---|
-d | Do not resolve IP addresses to hostnames. Tracert skips DNS lookups and displays numeric addresses only | Resolve hostnames | tracert -d example.com |
-h max_hops | Set the maximum number of hops tracert probes before stopping | 30 | tracert -h 15 example.com |
-w timeout | Set the timeout in milliseconds for each probe response. Tracert prints an asterisk (
*) if no response arrives | 4000 | tracert -w 3000 example.com |
-j host_list | Specify a loose source route along a list of intermediate hosts. IPv4 only. Multiple hosts are separated by spaces | N/A | tracert -j 203.0.113.1 example.com |
-R | Trace the round-trip path. IPv6 only | Off | tracert -R example.com |
-S src_addr | Set the source address for outgoing probes. IPv6 only | Default interface | tracert -S fe80::1 example.com |
-4 | Force tracert to use IPv4 | Auto-detect | tracert -4 example.com |
-6 | Force tracert to use IPv6 | Auto-detect | tracert -6 example.com |
Traceroute Error Code Reference
Traceroute appends error codes to hop output lines when a router returns an ICMP Destination Unreachable (Type 3) message. Each code maps to a specific ICMP sub-type.
| Code | ICMP Type 3 Sub-Code | Meaning |
|---|---|---|
!N | Code 0 | Network unreachable — no route exists to the destination network |
!H | Code 1 | Host unreachable — the specific host cannot be reached on the destination network |
!P | Code 2 | Protocol unreachable — the destination does not support the transport protocol used |
!F | Code 4 | Fragmentation needed but the Don't Fragment (DF) flag is set in the IP header |
!S | Code 5 | Source route failed — the specified source route cannot be followed |
!A | Code 13 | Administratively prohibited — a firewall or access control list (ACL) blocks the traffic |
* | N/A | No response received within the timeout period — the router silently drops the probe |