Linux and Unix traceroute command

Quick links

About traceroute
Syntax
Examples
Related commands
Linux and Unix main page

About traceroute

Print the route packets take to network host.

Syntax

traceroute [-d] [-F] [-I] [-n] [-v] [-x] [-f first_ttl] [-g gateway [-g gateway] | -r] [-i iface] [-m max_ttl] [-p port] [-q nqueries] [-s src_addr] [-t tos] [-w waittime ] host [packetlen]

-d Set the SO_DEBUG socket option.
-F Set the "don't fragment" bit.
-I Use ICMP ECHO instead of UDP datagrams.
-n Print hop addresses numerically rather than symbolically and numerically. This saves a nameserver address-to-name lookup for each gateway found on the path.
-v Verbose output. For each hop, the size and the destination of the response packets is displayed. Also ICMP packets received other than TIME_EXCEEDED and UNREACHABLE are listed as well.
-x Prevent traceroute from calculating checksums. Note that checksums are usually required for the last hop when using ICMP ECHO probes. See the -I option.
-f first_ttl Set the starting ttl value to first_ttl, to override the default value 1. traceroute skips processing for those intermediate gateways which are less than first_ttl hops away.
-g gateway Specify a loose source route gateway. The user can specify more than one gateway by using -g for each gateway. The maximum that can be set is 8.
-r Bypass the normal routing tables and send directly to a host on an attached network. If the host is not on a directly-attached network, an error is returned. This option can be used to send probes to a local host through an interface that has been dropped by the router daemon.
-i iface Specify a network interface to obtain the source IP address for outgoing probe packets. This is normally only useful on a multi-homed host. The -s option is also another way to do this. Note that this option does not provide a way to specify the interface on which the probe packets are sent.
-m max_ttl Set the maximum ttl used in outgoing probe packets. The default is 30 hops, which is the same default used for TCP connections.
-p port Set the base UDP port number used in probes. The default is 33434. traceroute hopes that nothing is listening on UDP ports (base+(nhops- 1)*nqueries) to (base+(nhops*nqueries)-1)at the destination host, so that an ICMP PORT_UNREACHABLE message will be returned to terminate the route tracing. If something is listening on a port in the default range, this option can be used to select an unused port range.nhops is defined as the number of hops between the source and the destination.
-q nqueries Set the desired number of probe queries. The default is 3.
-s src_addr Use the following address, which usually is given as an IP address, not a hostname, as the source address in outgoing probe packets. On multi-homed hosts, those with more than one IP address, this option can be used to force the source address to be something other than the IP address traceroute picks by default. If the IP address is not one of this machine's interface addresses, an error is returned and nothing is sent. When used together with the -i option, the given IP address should be configured on the specified interface. Otherwise, an error will be returned.
-t tos Set the tos(Type-of-service) in probe packets to the specified value. The default is zero. The value must be an integer in the range from 0 to 255. Gateways along the path may route the probe packet differently depending upon the tos value set in the probe packet.
-w waittime Set the time, in seconds, to wait for a response to a probe. The default is five (5) seconds.
host The network host.

Examples

traceroute computerhope.com

The above command will display results similar to the below example.

traceroute to computerhope.com (166.70.10.23), 30 hops max, 40 byte packets
1 198.60.22.1 (198.60.22.1) 2.303 ms 1.424 ms 2.346 ms
2 krunk3.xmission.com (198.60.22.6) 0.742 ms * 1.521 ms

Note: In the above example, we are doing a traceroute from the localhost, which causes the hops to be minimal. However, if you traceroute computerhope.com you will hop several more times than the above example.

This command is very useful for distinguishing network or router issues. If the domain does not work or is not available you can traceroute an IP to help determine where the problem exists.

Related commands

netstat
ping