Трассировка ip адреса linux

10+ traceroute command in Linux [Cheat Sheet]

traceroute is a command-line tool that displays the routes taken by network packets to reach the given host. It also helps to find slow traffic between source and destination. traceroute can come in handy when troubleshooting connectivity issues.

How to install traceroute

traceroute command is not available by default on most Linux distributions. You can use the following commands to install traceroute on your system.

Install traceroute on CentOS, RHEL, Fedora

$ sudo dnf install traceroute

Install traceroute on Ubuntu and Debian

$ sudo apt install traceroute

Syntax to use traceroute command

The syntax for the traceroute command is as follows:

host indicates the name or IP address of the destination host.

Different examples to use traceroute command

1. Trace the route to a network host

You can specify the domain name or IP address to trace the route to a network host.

The following example prints the route taken by packets to reach the host golinuxcloud.com .

$ traceroute golinuxcloud.com

Sample Output:

Читайте также:  Linux ssh config location

trace the route to a network host

The traceroute command displays the IP addresses through which the packets pass and the time taken by packets to reach the destination.

There are three instances of time in milliseconds as traceroute sends three packets in each hop.

If the destination is not reached, it prints asterisks like in hop 9. It can be caused due to a firewall blocking the network.

2. Trace the route using IPv4

The -4 option enables only IPv4 tracerouting to a network host.

$ traceroute -4 golinuxcloud.com

Sample Output:

traceroute using ipv4 protocol

3. Trace the route using IPv6

The -6 option allows you to use IPv6 protocol to trace the route to a network host.

$ traceroute -6 gtraolinuxcloud.com

Sample Output:

~]# traceroute -6 2a00:8a00:4000:293::1e0 traceroute to 2a00:8a00:4000:293::1e0 (2a00:8a00:4000:293::1e0), 30 hops max, 80 byte packets 1 2a00:8a00:4000:293::1e0 (2a00:8a00:4000:293::1e0) 0.074 ms 0.019 ms 0.016 ms

Or alternatively we can also use traceroute6 as shown below:

~]# traceroute6 2a00:8a00:4000:293::1e0 traceroute to 2a00:8a00:4000:293::1e0 (2a00:8a00:4000:293::1e0), 30 hops max, 80 byte packets 1 2a00:8a00:4000:293::1e0 (2a00:8a00:4000:293::1e0) 0.063 ms 0.017 ms 0.016 ms

4. Use ICMP ECHO

By default, the traceroute command uses the UDP ports for tracerouting. To use ICMP ECHO instead of UDP, run the command with -I option.

$ traceroute -I golinuxcloud.com

Sample Output:

traceroute using ICMP ECHO

5. Specify the maximum number of hops

The default maximum hops number is 30. You can change its value using the -m option.

$ traceroute -m hop_num golinuxcloud.com

Sample Output:

specify max hops in traceroute

6. Specify the interface

With -i flag, you can specify the interface you want to use to send packets to a host.

$ traceroute -i interface google.com

Sample Output:

Читайте также:  Установка нвидиа для линукс

specify interface in traceroute

7. Do not fragment packets

The -F option tells traceroute not to fragment probe packets.

$ traceroute -F golinuxcloud.com

Sample Output:

traceroute command to not fragment packets

8. Set the wait time

You can use the -w option to define time in seconds to wait for a response to the next hop. The default value is 5.0 seconds. The float point value is also allowed.

$ traceroute -w time golinuxcloud.com

Sample Output:

set wait time for a response

9. Set the number of probe packets per hop

The -q option lets you specify the number of probe packets for a hop. The default is 3.

$ traceroute -q num golinuxcloud.com

Sample Output:

The following example sends two packets in each hop to a host.

set number of probe packets per hop

10. Do not resolve IP addresses to their domain names

The -n option forces the traceroute command not to map IP addresses to their domain names when displaying them.

$ traceroute -n golinuxcloud.com

Sample Output:

do not resolve ip addresses to their domain names

11. Specify the destination port

The -p option is used to specify the destination port number for UDP tracing. The default port value is 33434.

$ traceroute -p port_num golinuxcloud.com

Sample Output:

specify the destination port

12. Set the full packet length

The default value of the full packet length is equal to the length of an IP header plus 40. You can change it by passing a new length to the traceroute command.

$ traceroute golinuxcloud.com packetlen

Sample Output:

change full packet length in traceroute

Conclusion

Now you should have understood how to use traceroute command to track the packet’s route to a network host. We have discussed the most common options used in traceroute commands. We hope you find this tutorial helpful.

If you have any confusion, let us know in the comment section.

Источник

traceroute command in Linux with Examples

traceroute command in Linux prints the route that a packet takes to reach the host. This command is useful when you want to know about the route and about all the hops that a packet takes. Below image depicts how traceroute command is used to reach the Google(172.217.26.206) host from the local machine and it also prints detail about all the hops that it visits in between.

Читайте также:  Узнать версию системы astra linux

The first column corresponds to the hop count. The second column represents the address of that hop and after that, you see three space-separated time in milliseconds. traceroute command sends three packets to the hop and each of the time refers to the time taken by the packet to reach the hop.

traceroute [options] host_Address [pathlength]

    -4 Option: Use ip version 4 i.e. use IPv4 Syntax:

-6 Option: Use ip version 6 i.e. use IPv6 Syntax:

-F Option: Do not fragment packet. Syntax:

-f first_ttl Option: Start from the first_ttl hop (instead from 1). Syntax:

$ traceroute -f 10 google.com

-g gate Option: Route the packet through gate. Syntax:

$ traceroute -g 192.168.43.45 google.com

-m max_ttl Option: Set the max number of hops for the packet to reach the destination.Default value is 30. Syntax:

-n Option: Do not resolve IP addresses to their domain names. Syntax:

-p port Option: Set the destination port to use. Default is 33434. Syntax:

$traceroute -p 20292 google.com

-q nqueries Option: Set the number of probes per each hop. Default is 3. Syntax:

packetlen Option: The full packet length. Default len is 60 byte packets. Syntax:

–help: Display help messages and exit. Syntax:

Источник

Оцените статью
Adblock
detector