ITZone

Learn ping, traceroute commands in network

Hello everyone, today I’m going to learn about ping and traceroute commands in the network

1. ping . command

Ping, short for Packet Internet Grouper, is a tool for computer networks used on TCP/IP networks to check if a connection is possible to a particular host, and to estimate the time interval. round-trip delay to send packets as well as the rate at which data packets can be lost between the two hosts.

Syntax:

Where targetname can be the IP of the server or a domain.

Some options on Linux:

-c <number>: stop after receiving <number> response from server

-t <number>: defines time to live

-v: show detailed results

You can use the ping –help command to see more options. Take a look at the example below: Based on the above results, we can know some information:

  • IP for domain is 8.8.8.8
  • ttl : the default ttl (time to live) value on Linux is 64, when going through each router station, the ttl value is reduced by 1, so based on this value we can know how much the packet goes through. station before reaching the destination, to know the details of the router stations that the packet has passed, we can use the traceroute command.
  • time : based on the time value returned in the ping command we can know the stability of the network, the closer the returned time values ​​are, the more stable the network is.

Some errors returned when using the ping command

  • Destination Host Unreachable : there is no path to the destination address or the destination address is wrong, when the ping command encounters this error it will return with the IP of the last place the packet reached.
  • Request time out : This error appears when the connection to the destination machine is not possible and there is no response. The cause of this error is that the router routers are turned off or the destination machine address is not real, is disabled or ping is prohibited.
  • TTL expired in transit : This error occurs when the TTL (Time To Live) value set for a ping packet drops to 0 while traveling through the network before reaching its destination. The cause could be:
  • The packet is looped between routers due to incorrect network settings, causing the TTL value to decrease by 1 as it passes through each router until the TTL value decreases to 0.
  • The TTL value of the packet is set too low.

To fix this error, you can use the traceroute command to see the details of the points the packet passes through

2. Command traceroute (tracert)

Traceroute (or tracert on Windows) is a computer network diagnostic tool for displaying routes (paths) and measuring the transit delay of data packets over an Internet protocol (IP) network.

traceroute uses the time to live expired ping message to know each hop the packet will have to go through before reaching its destination.

traceroute for what?

Know what the server’s address is pointing to (what and where) Know the rate of response when our packet passes through layer 3 devices (which are devices that provide capabilities such as routers, usually is the router – when going through these layer 3 devices, the IP will change to another IP) on the network. Know the number of hops and the number of devices that the packet has gone through Creates optimal paths (applies to slow networks, unexplained slow wifi and slow live streams)

Syntax:

Some options on Linux:

-I : use ICMP ECHO . protocol packet

-U : use TCP SYN . packet

-w <number> : configure response timeout, in seconds.

-f <number> : Specify a starting TTL value, default is 1, which means traceroute will show results with the first route in the path.

-q <number> : configure the number of response packets per hop (default is 3)

-m <number> : configure the maximum number of hops (maximum TTL value) to perform, default the maximum number of hops is 30.

You can use the traceroute –help command to see more options. Check out the example below Based on the above results, we can know the following information:

  • The server address for the above domain is 125.212.247.72 (server 24h.com.vn located at viettel – VietNam)
  • Our packet has to go through 12 routes before reaching its destination
  • Response time at each point ==> based on this we can determine where the delay is or where there is a problem on the network.
  • The hops (hops) are 13 -1 = 12
  • Above we can see that at some points, only the * sign is displayed, these are the points where the firewall is usually set, it allows our packet to pass but does not allow feedback for security reasons.

Epilogue

Thus, through this article, I share with you about the ping and traceroute commands in the network. If you have anything else to add, please leave a comment below. Good luck.!

 

Share the news now