The tracepath command is a simplified version of traceroute that does not require administrative privileges to run. It also contains fewer options. Many routing issues are the result of misconfigured routing tables. These issues can usually be fixed by updating the routing tables. However, you must first identify what is causing the issue. Commands like traceroute and tracepath can reveal routing issues like routing loops, in which traffic is continuously routed back and forth between multiple nodes and never reaches its destination. For example, node A uses node B as a path to node C; but node B uses node A as a path to C. If traffic is bound for node C, nodes A and B will endlessly send the traffic between them because they both think each other is the path to C.
Syntax
The syntax of the tracepath commands is:
# tracepath [options] {destination}
If you encounter the below error while running the tracepath command:
tracepath: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install iputils-tracepath |
Ubuntu | apt-get install iputils-tracepath |
Alpine | apk add iputils |
Arch Linux | pacman -S iputils |
Kali Linux | apt-get install iputils-tracepath |
CentOS | yum install iputils |
Fedora | dnf install iputils |
Raspbian | apt-get install iputils-tracepath |
traceroute V/s tracepath
The tracepath command is similar to the traceroute command, with two notable exceptions:
- The traceroute command can only be executed by the root user, whereas any user can use the tracepath command.
- The tracepath command lacks many of the options that the traceroute command provides. For example, it supports the -n option (display IP addresses, not hostnames) but not the -i and -g options that the traceroute command supports.
tracepath Command Examples
1. A preferred way to trace the path to a host:
# tracepath -p 33434 host
2. Specify the initial destination port, useful with non-standard firewall settings:
# tracepath -p destination_port host
3. Print both hostnames and numerical IP addresses:
# tracepath -b host
4. Specify a maximum TTL (number of hops):
# tracepath -m max_hops host
5. Specify the initial packet length (defaults to 65535 for IPv4 and 128000 for IPv6):
# tracepath -l packet_length host
6. Use only IPv6 addresses:
# tracepath -6 host
Conclusion
The tracepath command is used to trace the path from the origin to the destination. Each line in the tracepath output represents a router (hop) that the packet passes through.