Console9

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.

FlagDescriptionDefaultExample
-nDisplay numeric IP addresses only. Traceroute skips reverse DNS lookups, which speeds up the outputResolve hostnamestraceroute -n example.com
-m max_ttlSet the maximum Time to Live (TTL) value for outgoing probes. Traceroute stops after this many hops. Range: 1--25530traceroute -m 20 example.com
-w wait_timeSet the timeout in seconds for each probe response. Traceroute prints an asterisk ( *) if no response arrives within this period5traceroute -w 3 example.com
-q nqueriesSet the number of probe packets traceroute sends per TTL value. Range: 1--10003traceroute -q 1 example.com
-p portSet the base UDP destination port number. Traceroute increments this port for each probe. Range: 1--6553533434traceroute -p 44434 example.com
-i initial_ttlSet the initial TTL value for the first set of probes. Traceroute skips hops below this value1traceroute -i 5 example.com
-t tosSet the Type of Service (ToS) field in the IP header of outgoing probes. Range: 0--2550traceroute -t 16 example.com
-IUse ICMP Echo Request probes instead of the default UDP probes. Requires root privileges. ICMP probes often pass through firewalls that block UDPUDPsudo traceroute -I example.com
-TUse TCP SYN probes instead of UDP. Requires root privileges. TCP probes target port 80 by default and can bypass firewalls that allow HTTP trafficUDPsudo traceroute -T example.com
-4Force traceroute to use IPv4 transportAuto-detecttraceroute -4 example.com
-6Force traceroute to use IPv6 transportAuto-detecttraceroute -6 example.com
-s src_addrSet the source IP address for outgoing probes. The address must belong to a local interfaceDefault interfacetraceroute -s 192.168.1.10 example.com

Tracert Syntax on Windows

Windows uses the tracert command. The syntax is:

tracert [options] target_name

The 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.

FlagDescriptionDefaultExample
-dDo not resolve IP addresses to hostnames. Tracert skips DNS lookups and displays numeric addresses onlyResolve hostnamestracert -d example.com
-h max_hopsSet the maximum number of hops tracert probes before stopping30tracert -h 15 example.com
-w timeoutSet the timeout in milliseconds for each probe response. Tracert prints an asterisk ( *) if no response arrives4000tracert -w 3000 example.com
-j host_listSpecify a loose source route along a list of intermediate hosts. IPv4 only. Multiple hosts are separated by spacesN/Atracert -j 203.0.113.1 example.com
-RTrace the round-trip path. IPv6 onlyOfftracert -R example.com
-S src_addrSet the source address for outgoing probes. IPv6 onlyDefault interfacetracert -S fe80::1 example.com
-4Force tracert to use IPv4Auto-detecttracert -4 example.com
-6Force tracert to use IPv6Auto-detecttracert -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.

CodeICMP Type 3 Sub-CodeMeaning
!NCode 0Network unreachable — no route exists to the destination network
!HCode 1Host unreachable — the specific host cannot be reached on the destination network
!PCode 2Protocol unreachable — the destination does not support the transport protocol used
!FCode 4Fragmentation needed but the Don't Fragment (DF) flag is set in the IP header
!SCode 5Source route failed — the specified source route cannot be followed
!ACode 13Administratively prohibited — a firewall or access control list (ACL) blocks the traffic
*N/ANo response received within the timeout period — the router silently drops the probe