Our Knowledge Base provides step-by-step guides, troubleshooting tips, and expert insights to help you manage VPS, dedicated servers, domains, DDoS protection, and more — all designed to make your experience with us fast, secure, and stress-free.
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.
The syntax for the ping command is as follows:
ping [OPTIONS] DESTINATION
To better illustrate, how the ping command works let’s ping nexonhost.com:
ping nexonhost.com
The output will look something like this:
PING nexonhost.com (89.45.12.91) 56(84) bytes of data. 64 bytes from 89.45.12.91 (89.45.12.91): icmp_seq=1 ttl=63 time=0.527 ms 64 bytes from 89.45.12.91 (89.45.12.91): icmp_seq=2 ttl=63 time=0.637 ms 64 bytes from 89.45.12.91 (89.45.12.91): icmp_seq=3 ttl=63 time=0.577 ms 64 bytes from 89.45.12.91 (89.45.12.91): icmp_seq=4 ttl=63 time=0.573 ms 64 bytes from 89.45.12.91 (89.45.12.91): icmp_seq=5 ttl=63 time=0.610 ms ^C --- nexonhost.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4001ms rtt min/avg/max/mdev = 0.527/0.584/0.637/0.048 ms
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:
ping -c 1 DESTINATION
For example, to ping linuxize.com only one time you would use:
ping -c 1 nexonhost.com
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:
ping -I INTERFACE_NAME DESTINATION
The following command will ping linuxize.com using em2 as a source interface:
ping -I em2 nexonhost.com
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:
ping -4 DESTINATION
For IPv6, pass the -6 option or use ping6:
ping -6 DESTINATION
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.