How To Use Ping Command.
In this article, wee will explain how to use ping command.
ping is part of the iputils (or iputils-ping) package, which is pre-installed on nearly all Linux distributions. It is also available on Windows, macOS, and FreeBSD.
How to Use the Ping Command
The syntax for the ping command is as follows:
To better illustrate, how the ping command works let’s ping nexonhost.com:
The output will look something like this:
Specify the Number of Packets
As already mentioned, by default, ping will continue to send ICMP packages until it receives an interrupt signal. To specify the number of Echo Request packages to be sent after which ping will exit, use the -c option followed by the number of the packages:
For example, to ping linuxize.com only one time you would use:
Specify the Source Interface
The default behavior of the ping command is to send ICMP packages via the default route. If you have multiple interfaces on your machine you can specify the source interface with the -I option:
The following command will ping linuxize.com using em2 as a source interface:
Specify the Internet Protocol
When you run the ping command, it will use either IPv4 or IPv6, depending on your machine DNS settings.
To force ping to use IPv4, pass the -4 option, or use its alias ping4:
For IPv6, pass the -6 option or use ping6:
ping is a command-line network utility that allows you to test the IP-level connectivity of a given host on the network.
To view all available options of the ping command, type man ping in your terminal.