The ping (Packet Internet Groper) command is an extensively used tool for identifying network connectivity issues. It sends ICMP (Internet Control Message Protocol) packets to a destination (IP address, hostname, or domain) and waits for a reply. The response time, measured in milliseconds, shows the latency or connection speed. The lower the latency, the faster the connection.
This command is ideal for troubleshooting network issues. If no response is received, it usually indicates a connectivity problem, possibly due to firewall settings on the involved servers.
You will learn how to use the ping command and how to perform a ping test on Linux.
- To execute the command and check for connectivity issues with an IP address, hostname, or domain name, enter the following in your command-line interface:
ping <IP/hostname/domain>
- Here is an example of a successful result when using it:
[root@server ~]# ping google.com PING google.com (172.217.18.174) 56(84) bytes of data. 64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=1 ttl=58 time=0.716 ms 64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=2 ttl=58 time=0.865 ms 64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=3 ttl=58 time=1.01 ms 64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=4 ttl=58 time=0.859 ms 64 bytes from fra15s29-in-f14.1e100.net (172.217.18.174): icmp_seq=5 ttl=58 time=1.06 ms
- Note that before sending the ICMP request, the ping command converts the domain or hostname to an IP address. When the command completes or is interrupted with “CTRL + C”, a summary will be displayed, showing the number of packets transmitted, received, and the percentage of packet loss, if any.
--- google.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4004ms rtt min/avg/max/mdev = 0.716/0.903/1.065/0.126 ms
- By default, ping will continue sending packets until it is terminated or receives an interrupt signal. You can specify the number of echo packets to send using the “-c” flag.
- The final flag we’ll discuss is the Internet Protocol flag, which allows you to specify whether to ping an IPv4 or IPv6 address. Here are two examples:
[root@ger1 ~]# ping -c 2 -4 google.com PING google.com (172.217.16.142) 56(84) bytes of data. 64 bytes from fra15s46-in-f14.1e100.net (172.217.16.142): icmp_seq=1 ttl=58 time=0.786 ms 64 bytes from fra15s46-in-f14.1e100.net (172.217.16.142): icmp_seq=2 ttl=58 time=0.805 ms --- google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.786/0.795/0.805/0.029 ms [root@ger1 ~]# ping -c 2 -6 google.com PING google.com(fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e)) 56 data bytes 64 bytes from fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e): icmp_seq=1 ttl=58 time=0.729 ms 64 bytes from fra02s19-in-x0e.1e100.net (2a00:1450:4001:808::200e): icmp_seq=2 ttl=58 time=0.735 ms --- google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.729/0.732/0.735/0.003 ms
In this manner, you can use the ping command and perform a ping test on Linux.
If you use Windows, learn how to perform ping checks on Windows to enhance your network testing skills and ensure optimal performance.
If you need further assistance, do contact our support staff.