Get The Most Out of Ping Command

When we want to check the network connectivity of any network connected device or the web server we use the Ping command.

The Ping command sends data packets to the remote server or to the remote device and when we get replies that means the remote device is active and responding to our query.

To start the program, click on start menu and type CMD.

This will open up a command prompt from where we can use PING command. When we try to ping www.google.com we will get a reply like this:

It will first resolve the DNS of www.google.com and shows the IP address of www.google.com. In next line it shows the replies that computer receives from the server IP address. It basically sends 32 bytes of data and get it back in 184 milliseconds it also tells the TTL (time to live) value as well.

The basic ping command sends 4 consecutive packets to the destination server or network device for initial investigation. We can also send many packets as per our requirements like we can send continuous ping so that whenever the device goes down we will notice that immediately.

After all the 4 packets sent we get a summary at the end of the command output. The summary shows how many packets were sent, how many packets were received and how much was the packet loss.

As the ping works something like you send a packet to the remote server or device and that device sends that packet back to the sender to let the sender know that it received the packet that was sent to it. So, in the summary it shows approximate round-trip times for the packets as the minimum time taken to complete the round trip, the maximum time taken, and the average time taken to complete the round trip of the packet that we sent.

We can also set a continuous ping so that whenever the remote server or the device goes down we will notice that immediately. To send a continuous ping we need to use -t attribute.

As you can see with -t attribute the ping is not limited to 4 packets sent and receive as its continue in a sequence that it sends a packet and it receives. It shows the status and then it sends again and again, and it continues. We can keep the ping window active to monitor the device status for the critical devices so that whenever the device or the link goes down we will immediately take the required action. You can stop this ping by pressing CTRL+C key combination. It will not show you the summary at the termination of command.

We can also use the ping command to get the hostname against the IP address. For this purpose, we use Рan attribute.

Here I have pinged my local IP address with -a attribute and it gives me the computer name in the first line.

With ping, you can also check IPv6 IP address of the server using -6 attribute.

In this example, I have ping my own computer with IPv6 and in ping reply, I get the IPv6 assigned to my computer.

You can also send a ping command using multiple attributes to get more in detail data for analysis.

Like in the above example I have sent a ping command with attribute -n saying to send 10 packets and to resolve IPv6 for the computer name ImranPC. So, it gives us the summary saying that 10 packets sent, received and zero was loss and it resolved the hostname or the computer name with IPv6.

The time to live TTL value is very important when using a ping command. It is a timer value that is being added in the packet we are sending to the destination and tells the recipient how long to hold that packet before expiring or discarding the packet. It also helps us to understand the operating system running on the destination.

In the above example, I have ping my local computer at my lab and I got the TTL value 128. This means I am running a Windows based computer.

In the above example, I ping www.google.com and I get a TTL value of 54 which is indicating that the website www.google.com is hosted on a Linux server.

In ping command, we get the flexibility to specify our own TTL irrespective of the destination operating system. The -I attribute to allow us to specify the TTL value. The maximum value we can set for TTL is 255. When will send the TTL value through our ping command it overwrites the destinations TTL value at the destination host or device holds the packet to the TTL value defined by the sender.

In the above image, you can see that we have modified the TTL value and sending it to www.google.com. The server is responding in the Ping response with TTL 54 which is by default set for the google.com server.

There are some other operators available with ping command which you can use. You can also use the help switch operator after the Ping command to see all the supported attributes of the Ping command on your operating system.

You May Also Like

About the Author: Muhammad Imran Habib

Imran is a technology evangelist with 8 years of experience working with some of the Industry leading companies. Imran's expertise includes On-Prem/Virtual Infrastructure deployments, IT Solutions for SMEs, End User Computing Support.

Leave a Reply

Your email address will not be published. Required fields are marked *