Use Ping Command | Shell Command

Linux Ping Command Laptop

Ping(Packet Internet Groper) command is a widely used command-line utility used in networking. Ping is used to check network issues like host/server is active or not, and their latency.

Latency is, how much time your host/server takes to respond back.you can check ping by IP address or a domain name.

Ping used to send ICMP(Internet Control Message Protocol) packets to server/host to check that its up or not. If the host/server is up then its reply back with ICMP protocol.

This whole process called (ICMP echo request), when you ping, that packet called ICMP echo request, then server reply with packets that packets called ICMP echo reply. This echo request works in milliseconds. Nowadays ping utility is pre-installed in operating systems.

Let’s start use ping Command in Linux. Linux has more arguments to use with the ping command. you can get pro-level output in Linux when you use ping.

Command In Linux Output
Ping Command In Linux Output

In above Image, I ping a domain name google.com and ping utility gives me lots of information about that

64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=56 time=48.5 ms

vary first line shows google IP address which is 172.217.166.206, after that we see ping utility send 64 bytes packet to check that server is up or not.

Ping statistics show seven packets are sent and seven packets are received. there are no packet loss and the total time to complete this procedure is 6007ms. The default ping command sends unlimited packets until you press ctrl + c to cancel. nowhere you can use ping arguments to control this

Use ping with its Arguments

ping<space>-c<space>(count value) google.com

A ping -c argument will send only 3 packets to your IP/domain you don’t have to cancel ping request manually

command utility with c argument
ping utility with c argument

Command ping<space>-b

The b argument allows you to ping your broadcast address which you cant ping normally.

Command ping <space>-p 192.168.1.3

This is useful for diagnosing data-dependent problems in a network. For example, -p ff will cause the sent packet to be filled with all ones.

ping command option p
ping option p

Command ping<space>-t<space>(TTL value)

The TTL value of an IP packet represents the maximum number of IP routers that the packet can go through before being thrown away. In current practice, you can expect each router in the Internet to decrement the TTL field by exactly one.

The maximum possible value of this field is 255, and most Unix systems set the TTL field of ICMP ECHO_REQUEST packets to 255. This is why you will find you can ping some hosts, but not reach them with telnet.

Command ping -s

The s option is used to change the packet size. By default, ping sends 56 which became 64 with ICMP header data packets, with increasing packet size you put more load on host/server so we send 100 bytes data will become 108 bytes.

ping command output wits s
ping command output wits s

Command ping<space>-w<space>(timeout value)

The w argument you can specify ping command timeout. The timeout value is in seconds. if you give 10 seconds time so it will stop ping after 10 seconds.

LInux ping command with w
ping w argument

Command ping<space>-I<space>(interface name)

With I argument you can ping IP or domain with a specific interface. below the image, you see when I use that I argument I see the output of ping, but when I change my interface ping gives me an error that IP is bind to a different device.

Ping command with I argument
Ping command with I argument

Key Things to remember when use ping

  • When using ping to check network issue, it should first be run on the localhost, to verify that the local network interface is up and running.
  • If duplicate packets are received, they are not included in the packet loss calculation, although the round trip time of these packets is used in calculating the minimum/average/maximum round-trip time numbers.
  • All Arguments are case sensitive.

Reference: ubuntu manpage Linux can home page

Please Improve this article if you find anything incorrect so please comment below and I will update.

Leave a Comment

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