Installing Traceroute on your VPS or Dedicated server is really easy. It takes no more than a minute. Traceroute is a network diagnostic tool that can help you find the causes of network connectivity problems.
In this article, I will show you the simple steps to install Traceroute in CentOS, Ubuntu, and other flavors of Linux. I will also show you how to run the command to diagnose network connectivity problems.
What is Traceroute
Traceroute is a command-line network diagnostic tool. It helps you identify network connectivity problems by showing you the route packets take to reach their destination or network host.
How To Install Traceroute in CentOS 6/7, Oracle Linux 6/7, Linux RHEL 6/7
To check if your computer or VPS server has the traceroute tool installed on it, simply open up the command line or connect to your server via SSH and run the following command:
# traceroute google.com
Traceroute’s not installed if you see the following error/warning in your terminal:
-bash: traceroute: command not found
Before you can install Traceroute, let’s make sure your system is up-to-date and has the latest list of available packages by running these two commands:
# yum clean all # yum -y update
Now, you can install Traceroute by running this install command:
# yum install traceroute -y
Installing Traceroute usually takes only a couple of seconds. Once it’s done installing, you can verify it’s installation location by running this command:
# which traceroute
If Traceroute was installed successfully, you will see an output similar to this:
How To Install Traceroute On Ubuntu
Installing Traceroute on Ubuntu is really simple.
First, run the update command:
# sudo apt-get update
Now, run the installation command:
# sudo apt-get install traceroute
That’s it. That’s all you need to do.
To verify if it’s been installed, run the which command:
# which traceroute
If the installation was successful, you will see something similar to this:
How To Use The Traceroute Command In CentOS/Linux
The Traceroute command is very simple to use. Just run the command with the name of the destination (IP or website):
If it works, you should see something similar to this:
traceroute to www.google.com (220.127.116.11), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * 4 * * * 5 eqix-ch-200g-1.google.com (18.104.22.168) 2.878 ms * 2.844 ms 6 22.214.171.124 (126.96.36.199) 2.627 ms 2.626 ms eqix-ch-200g-1.google.com (188.8.131.52) 3.319 ms 7 184.108.40.206 (220.127.116.11) 1.704 ms 18.104.22.168 (22.214.171.124) 3.577 ms 3.202 ms 8 126.96.36.199 (188.8.131.52) 1.677 ms 1.711 ms ord38s29-in-f14.1e100.net (184.108.40.206) 1.896 ms
Find Network Path
Run the following command to find the network path from your server to destination (google.com) without resolving IP addresses to their domain names:
# traceroute www.google.com -n
Change Response Wait Time
If you want to change the amount of time Traceroute waits for response, you can pass the -w flag with the number of seconds you want to wait. The default is 5 seconds.
The following command will only wait 2 seconds for a response:
# traceroute www.google.com -w 2
Display All The Options
Passing the –help flag to the Traceroute command gives you a basic list of all the options you have at your disposal when running this command:
# traceroute --help
Here’s what the output should look like:
Usage: traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ] Options: -4 Use IPv4 -6 Use IPv6 -d --debug Enable socket level debugging -F --dont-fragment Do not fragment packets -f first_ttl --first=first_ttl Start from the first_ttl hop (instead from 1) -g gate,... --gateway=gate,... Route packets through the specified gateway (maximum 8 for IPv4 and 127 for IPv6) -I --icmp Use ICMP ECHO for tracerouting -T --tcp Use TCP SYN for tracerouting (default port is 80) -i device --interface=device Specify a network interface to operate with -m max_ttl --max-hops=max_ttl Set the max number of hops (max TTL to be reached). Default is 30 -N squeries --sim-queries=squeries Set the number of probes to be tried simultaneously (default is 16) -n Do not resolve IP addresses to their domain names -p port --port=port Set the destination port to use. It is either initial udp port value for "default" method (incremented by each probe, default is 33434), or initial seq for "icmp" (incremented as well, default from 1), or some constant destination port for other methods (with default of 80 for "tcp", 53 for "udp", etc.) -t tos --tos=tos Set the TOS (IPv4 type of service) or TC (IPv6 traffic class) value for outgoing packets -l flow_label --flowlabel=flow_label Use specified flow_label for IPv6 packets -w MAX,HERE,NEAR --wait=MAX,HERE,NEAR Wait for a probe no more than HERE (default 3) times longer than a response from the same hop, or no more than NEAR (default 10) times than some next hop, or MAX (default 5.0) seconds (float point values allowed too) -q nqueries --queries=nqueries Set the number of probes per each hop. Default is 3 -r Bypass the normal routing and send directly to a host on an attached network -s src_addr --source=src_addr Use source src_addr for outgoing packets -z sendwait --sendwait=sendwait Minimal time interval between probes (default 0). If the value is more than 10, then it specifies a number in milliseconds, else it is a number of seconds (float point values allowed too) -e --extensions Show ICMP extensions (if present), including MPLS -A --as-path-lookups Perform AS path lookups in routing registries and print results directly after the corresponding addresses -M name --module=name Use specified module (either builtin or external) for traceroute operations. Most methods have their shortcuts (`-I' means `-M icmp' etc.) -O OPTS,... --options=OPTS,... Use module-specific option OPTS for the traceroute module. Several OPTS allowed, separated by comma. If OPTS is "help", print info about available options --sport=num Use source port num for outgoing packets. Implies `-N 1' --fwmark=num Set firewall mark for outgoing packets -U --udp Use UDP to particular port for tracerouting (instead of increasing the port per each probe), default port is 53 -UL Use UDPLITE for tracerouting (default dest port is 53) -D --dccp Use DCCP Request for tracerouting (default port is 33434) -P prot --protocol=prot Use raw packet of protocol prot for tracerouting --mtu Discover MTU along the path being traced. Implies `-F -N 1' --back Guess the number of hops in the backward path and print if it differs -V --version Print version info and exit --help Read this help and exit Arguments: + host The host to traceroute to packetlen The full packet length (default is the length of an IP header plus 40). Can be ignored or increased to a minimal allowed value