Ping is one of the most used networking commands.
In today’s article, you’ll learn what it is, how to use it, online ping tools, and some practical examples.
First of all, let’s see what ping is. Ping is a Terminal / Shell command utility used as a simple way to verify that a machine has internet access and can communicate with other computers or network devices.
Some of the functions of the ping command are :
- Test network connectivity: local network, internet
- Troubleshoot network interface card
- Test DNS name resolution issues
Maybe, you’ve seen ping in normal conversations, for example, “I’ll ping you once I’m done with the work”. In common language, ping simply means a message sent from a computer to another.
To check you have ping installed, fire up a terminal (macOS, Linux) or command prompt (Windows), and type “ping –help”. In most cases, you should see something like this.
If you get a help section with a list of flags to use, you’re good to go. In some Linux distributions like Ubuntu, you may have trouble because ping isn’t installed by default. In Ubuntu, you can install ping with:
sudo apt install iputils-ping
Another way to test ping is installed in your system would be using which, that returns the path of any binary installed in your system:
which ping # /usr/bin/ping # My result
Now that you can use ping with no problem, it’s time to learn its basic usage.
The ping command connects to any host available, whether in your local network or over the internet. That host can be another computer, server, router, or even a printer.
Ping accepts one argument, which is the web or IP address you’re trying to connect to. For example, we’ll try to connect to geekflare.com.
$ ping geekflare.com
Remember the “$” sign means we’re using a bash shell; in Powershell (Windows), it would be “>”. You should only copy the command and not the dollar sign.
After typing the above command, you should see something like the following:
PING geekflare.com (18.104.22.168) 56(84) bytes of data. 64 bytes from 22.214.171.124 (126.96.36.199): icmp_seq=1 ttl=57 time=64.1 ms 64 bytes from 188.8.131.52 (184.108.40.206): icmp_seq=2 ttl=57 time=71.4 ms
First, it indicates the domain name we’re trying to connect to and its IP address within parenthesis. Then, it sends packets of bytes of data (usually 64) to the desired destination. To stop the ping command, just press Ctrl + C.
If you have a stable internet connection (which I’m sure you do since you’re reading this), you should get a message similar to the one below:
--- geekflare.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 10192ms
This message shows the statistics of the pinging process you did to a domain name or IP address. As you can see, ping sent 3 packets of data, and it received all of them. That means both your internet connection and the hosting service that serves the IP address is working perfectly.
That same process occurs when you visit a web page, you (your browser) send packets of data with a request, the DNS (domain name service) translate the domain name to a real IP address, and then the host transmits the content of the page back to us. Of course, we’re skipping a lot of things, but this is just an explanation about a simple network interaction.
As a pro-tip, anytime you need a list of the available flags, you can call its manual page with man or the –help flag.
man ping # Manual page ping --help # Help flag
IPv6 vs. IPv4
The world is running out of IP addresses, and as a result, we’re starting to implement IPv6 (Internet Protocol version 6).
Shortly explained, IPv4 is the core IP protocol that runs the web. It uses a 32-bit IP address, including a numeric-dot notation. For example, Google’s main IP address is 220.127.116.11. IPv4 has been here since 1981, and it’s the normal protocol we’re used to seeing.
On the other hand, IPv6 is another IP protocol that solves the problem of getting out of address. If IPv4 has up to 4.3 billion combinations, IPv6 could have 340 trillion trillion trillion IP addresses.
Here is an example of an IPv6 address: 2001:db8:3333:4444:5555:6666:7777:8888.
In other words, we’ll be transitioning to IPv6 addresses in the next few years because every IOF (internet of things) device and upcoming websites will need new addresses.
Ping already supports IPv6 addresses, and in some Linux distributions, you can find an exclusive command, ping6, for them.
However, the best way to ping an IPv6 address is using the -6 flag.
Here’s an example:
ping -6 2001:db8:3333:4444:5555:6666:7777:8888
If your network doesn’t support IPv6 yet, don’t worry. IPv6 adaption has been growing ginormously in recent years.
Use the IPv6 testing tool to check if your website supports it.
Online Ping Services
Ping only usage isn’t to determine if you’re able to reach a specific server, but also to get the latency (time that it takes ping to receive a response) of your request to a server. Online ping tools allow you to gather much more data about the ping processes like
On the other hand, if you’re having a bad time with your connectivity or just want to test out your server latency from different locations worldwide, an online Ping tool is your best choice.
Check out our free online ping tool, and perform pings from London, Mumbai, and Oregon. Using this tool, you’ll get important data like packet loss and the maximum and minimum time it takes to get a response from your server.
Let’s test and see some of the frequently used examples of this networking tool.
#1. Check Your Internet connection
This may seem obvious, but you can check you have access to the Internet by pinging (the action of using ping) a solid target host like google.com.
If you don’t get any response, it’s likely your Internet connection isn’t working properly.
#2. Send a Determined Amount of Pings
One problem you may encounter if you’re using a Unix machine is that ping sends packets of data indefinitely. With the flag -c (count), you can specify the number of pings you want to make. For example, if you want to ping exactly three times, you would do.
ping -c 3 geekflare.com
Note: This doesn’t occur in Windows where ping sends only 4 data packets
You can use this flag to send only a ping request and display the IP address of the destination you’re trying to reach.
ping -c 1 google.com
#3. Ping a Server Within an Interval
You can set an interval of seconds between sending each packet. The default interval is one second, but you can modify it with the -i flag.
ping -i 3 geekflare.com
#4. Ping localhost
You can ping any IPv4 address; hence, you’re able to ping your localhost using either the localhost label or the IP address 127.0.0.1.
ping localhost # works fine ping 127.0.0.1 # works fine too
Ping won’t pass through a physical network interface but through a virtual loopback.
#5. Pinging a Broadcast
You can use the -b flag to send requests to a broadcast address. For example, you can ping all the devices in your local network with the following command.
ping -b 255.255.255.255
#6. Send a Specific Packet Size
Depending on your needs, you can change the packet size of your ping using the -s flag with the number of bytes you want to send.
ping -s 70 google.com
Note that some requests may not work if you send a big size packet.
#7. Flood ping
The -f flag sends ping requests as fast as your computer and network can. Since the minimal ping interval allowed to the user is 200ms, you must run it as a superuser with the command sudo.
ping -f google.com PING google.com (18.104.22.168) 56(84) bytes of data. ping: cannot flood; minimal interval allowed for user is 200ms sudo ping -f -c 1000 google.com # Stop after 1000 pings --- google.com ping statistics --- 1000 packets transmitted, 1000 received, 0% packet loss, time 11158ms
As you can see, I used the count flag to stop sending requests once it hit 1000 times (notice how it only took 11 seconds).
Note: Be extremely careful using “flood ping” since you could cause a DoS (denial of service) to the server you’re pinging. The only situation you should use this is to test your server in high-intensity environments.
IP or Domain Ping API
Geekflare Ping API is a handy tool that can help you track any IP or Domain’s performance from multiple locations.
This can prove vital for keeping tabs on a range of servers to ensure an optimal end-user experience.
And what’s more, you can easily do that with Geekflare’s API free tier that gifts 3000 API calls per month.
For the pros, the premium plans add residential proxies, a greater request rate, and a higher number of API calls starting with only $5 a month.
A ping is a tool practically as old as the Internet itself. With it, you can determine whether you have an active internet connection or not and test if you’re able to reach web servers or other networking devices.
More great readings on Sysadmin
Looking For Traceroute on RHEL 8? Try TracepathAbhishek Nair on June 14, 2022
6 Best Switch Port Monitoring ToolsDurga Prasad Acharya on June 12, 2022
Windows 10/11 Random Shutdown: How to Find the CauseHitesh Sant on May 30, 2022
7 Best Server Configuration Monitoring and Auditing ToolsTalha Khalid on May 28, 2022
8 Best FTP Server Software for Windows for Secure TransferSatish Shethi on May 24, 2022
OSI Model Layers: An Introduction GuideAmrita Pathak on May 13, 2022
Join Geekflare Newsletter
Every week we share trending articles and tools in our newsletter. More than 10,000 people enjoy reading, and you will love it too.