Categories: Unix Tutorials

How to use Ping Command in Unix | Ping Command Examples

Ping Command :

In UNIX, there are lot of communication utilities and user needs to use set of UNIX commands. I have already explained about the file creation in UNIX using multiple ways. When you work in distributed environment, you need to communicate with remote users and need to access remote machines. The Ping Command in UNIX is used to test ability of source computer to reach specified destination. The Ping command is used to check the connectivity with your source computer with the set of devices in the network. It usually sends the request to the computer in the network or device in the network .If user will get proper reply then the network is working properly.

The ping command is used to isolate the network hardware problems.

Tasks of Ping command :

If you are thinking that the ping is very simple command used to check the connectivity of the network, there are other uses of ping command.

1.Ping To diagnose connectivity :

First and most important use of ping command is to diagnose the network connectivity.

Check TCP-IP Connection :

Ping the loopback address to check TCP-IP connection is working fine.

Example :

Ping 127.1.0.1

Output :

Pinging 127.1.0.1 with 1450 bytes of data:

Reply from 127.1.0.1 bytes=1450 time<10ms TTL=32

Reply from 127.1.0.1: bytes=1450 time<10ms TTL=32

2.Ping IP address of local computer / Default gateway / remote host :

User can ping the ip address of local computer to check it is added to network correctly.User can check the connectivity of default gateway as well as remote host.

Example:

ping 10.14.129.23

Output:

Pinging 10.14.129.23 with 32 bytes of data:

Reply from 10.14.129.23: bytes=32 time<1ms TTL=128

Reply from 10.14.129.23: bytes=32 time<1ms TTL=128

Reply from 10.14.129.23: bytes=32 time<1ms TTL=128

Reply from 10.14.129.23: bytes=32 time<1ms TTL=128

Ping statistics for 10.14.129.23:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

3.Increase or decrease the time interval between packets :

By default the Ping Command will wait till 1 second to send next packet.User can increase or decrease the packet interval by using –i option of ping. Only super user can specify interval less than 0.2 seconds.

Examples :

$Ping – I 5 10.14.129.23

The above ping command will wait 5 seconds before sending next packet.

$Ping – I 0.1 10.14.129.23

The above ping command will wait 1 milliseconds before sending next packet.

4.Show the version :

The –V option of ping is used to show the version and exit. The –V option is used to show the current version of ping program.

Example :

$Ping –V

Output :

ping utility, iputils-sss20181127

5. Send N packets in network :

-c option of ping command will send N packets over the network and then exit. Using this option the ping command will exit automatically rather than pressing CTRL + C to exit.

Example : 

$Ping –c  5 10.94.122.201

The above ping command will send 5 packets over the network and waits for response from destination .The ping will exit after response or error.

6.Audio ping :

The –a option of ping command is used for audible ping.This option is useful for system admin for troubleshooting. You can continue working with your changes, and when the remote machine become reachable you’ll hear the beep automatically. The disadvantage of this option is this option will not work with console.

Example :

$Ping –a   10.94.122.201

The user will get the beep sound after the remote computer is reachable.

7.Changing the Ping packet size :

Ping command is used to change the packet size using – s option of command.

Example :

$Ping –s 100 10.94.122.201

Output :

PING 10.94.122.201 (127.0.0.1) 100(128) bytes of data.

Formula :

Ping Bytes Sent = Ping Packet Size + Ping Header Packet Size (28 bytes)

The size is showing 128 which is nothing but the Packet header size + packet size. The packet size is 100 and its header size is 28.

8. Timeout option of Ping Command :

User can set the specific time to send the packets in the network. This actually specifies the total number of seconds the Ping command to send the packet to remote host. If you specify the less time then the timeout error will come.

Example :

ping -w 0.2 10.14.129.23

 Output : 

Pinging 10.14.129.23 with 32 bytes of data:

PING: transmit failed. General failure.PING: transmit failed. General failure.

PING: transmit failed. General failure.

PING: transmit failed. General failure.

Ping statistics for 10.14.129.23:

Packets: Sent = 4, Received = 0, Lost = 4 (100% loss).

9. Checking reachability of your server from different locations :

User can use the ping command to check the reachability of your server from different locations. There are different websites, which will give the status of your server from worlds different locations.

Check the screenshot:

 

These are some different uses of the Ping command. If you will get the error in ping command then user needs to check some points to resolve the error of server.

Resolution of Error ‘Request time out’ :

If the network is not working properly or terminal is not in the network then Request time out error will come.Following are basic checkpoints to resolve this error :

1.Check Firewall :

Most of the times the Ping Command is blocked at firewall level. User needs to check that and configure the firewall to allow ping command network access. For personal firewall user needs to allow the ICMP Echo and Echo Reply Packets.

2.Check Router Status :

Sometimes the router is down and due to that there is problem in network connectivity. Try to use tracert command to check the path between source and destination.

3.Destination Host Down :

Check the physical connectivity of destination host. When the destination host will down then Request time out error will come.

4.Check Response latency :

Sometimes latency of response is more than one seconds so the Request time out error will come. In that case, using – w increase the timeout of packet send and receive.

Destination net unreachable :

Sometimes user will get error ‘Destination net unreachable’. This error will come when there was no route to the destination.User need to check the routing table and reply from address is correct or not in  routing table.

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Share
Published by
Amit S

Recent Posts

What is Root Cause Analysis (RCA) With real examples

In my previous article I have given details about application support engineer day to day…

1 month ago

Application Support Engineer Day to day responsibilities

In my previous articles I have given the roles and responsibilities of L1,L2 and L3…

1 month ago

What is mean by SLA ( Service Level Agreement) with Examples?

In my previous articles i have given the hierarchy of production support in real company…

1 month ago

What is Production support Hierarchy in organization?

In this article i would like to provide information about production support organization structure or…

1 month ago

What are roles and responsibilities for L3 Support Engineer?

In my previous article I have given roles for L1 and L2 support engineer with…

1 month ago

What are roles and responsibilities of L2 Engineer?

I have started this new series of how to become application support engineer. This article…

1 month ago