Skip to content

traceroute MacOS Command Guide

The MacOS traceroute command is a powerful tool used to trace the path that your packets take to a destination IP address. By sending a series of packets with increasing Time-To-Live (TTL) values, traceroute identifies the routers that these packets pass through before reaching the final destination. This command can help you diagnose network issues, identify bottlenecks, and optimize your network performance. With MacOS, you can use the traceroute command in the Terminal to troubleshoot connectivity problems and gain valuable insights into your network topology.

traceroute Syntax:

Terminal window
traceroute [ -AcdDeFInrSvx ] [ -f first_ttl ] [ -g gateway ] [ -i interface ] [ -M first_ttl ] [ -m max_ttl ] [ -p port ] [ -q nqueries ] [ -s source_addr ] [ -T tos ] [ -w waittime ] [ -z sendwait ] host [ packetlen ]

Options:

OptionDescription
-AUse AS path lookups to map addresses to ASN (Autonomous System Number) names
-cExit after sending count queries num
-dSet the SO_DEBUG option in the socket
-DPrint the timestamp of the time to live (TTL) replied to
-eShow the initial time-to-live (TTL) value used in probes
-FSet the “don’t fragment” bit
-IUse ICMP ECHO instead of UDP datagrams for probes
-nDo not try to map IP addresses to hostnames
-rBypass the normal routing tables and send directly to a host
-SPrint the AS numbers in the paths
-vVerbose output
-xShow maximum time to live (TTL) exceeded replies and ICMP not in the same sequence

Parameters:

ParameterDescription
hostThe destination host to trace the route to
packetlenLength of outgoing packets (optional)

traceroute Command Samples:

Basic traceroute

Terminal window
traceroute www.google.com

Performs a traceroute to the website “www.google.com” to determine the route taken by packets across a network.

Display IP Addresses

Terminal window
traceroute -n www.facebook.com

Performs a traceroute to the website “www.facebook.com” and displays IP addresses instead of hostnames in the output.

Set Maximum Hops

Terminal window
traceroute -m 15 www.amazon.com

Performs a traceroute to the website “www.amazon.com” with a maximum of 15 hops to reach the destination.

Use ICMP Echo Requests

Terminal window
traceroute -I www.reddit.com

Performs a traceroute to the website “www.reddit.com” using ICMP echo requests (ping) to probe the intermediate hops.

Use UDP Packets

Terminal window
traceroute -U www.twitter.com

Performs a traceroute to the website “www.twitter.com” using UDP packets instead of ICMP to determine the route to the destination.

Display Timestamps

Terminal window
traceroute -T www.apple.com

Performs a traceroute to the website “www.apple.com” and displays timestamps in the output to analyze the round-trip times of packets.

Set Packet Size

Terminal window
traceroute -s 1000 www.microsoft.com

Performs a traceroute to the website “www.microsoft.com” with a packet size of 1000 bytes to test network performance and compatibility.

traceroute FAQ:

How do I use traceroute in MacOS?

To use the traceroute command in MacOS, execute the following command:

Terminal window
traceroute google.com

What are some common options used with traceroute in MacOS?

Common options used with the traceroute command in MacOS include setting the maximum TTL with ‘-m’ and using numeric output for addresses with ‘-n’. For example:

Terminal window
traceroute -m 15 -n google.com

How can I perform a reverse DNS lookup with traceroute in MacOS?

To perform a reverse DNS lookup with the traceroute command in MacOS, you can use the ‘-R’ option. Here is an example:

Terminal window
traceroute -R google.com

How do I stop traceroute from resolving IP addresses to hostnames in MacOS?

To stop traceroute from resolving IP addresses to hostnames in MacOS, use the ‘-n’ option. This will display numeric addresses only. For example:

Terminal window
traceroute -n google.com

Can I change the timeout value for traceroute in MacOS?

Yes, you can change the timeout value for traceroute in MacOS using the ‘-w’ option followed by the desired timeout in seconds. Here is an example:

Terminal window
traceroute -w 2 google.com

How can I save the traceroute output to a file in MacOS?

To save the traceroute output to a file in MacOS, you can use the ’>’ symbol followed by the desired file name. For example:

Terminal window
traceroute google.com > traceroute_output.txt

Applications of the traceroute command

  • Diagnosing network connectivity issues
  • Identifying network bottlenecks
  • Troubleshooting slow internet connections
  • Analyzing routing paths taken by network packets
  • Determining the latency between hops on a network path