How to Use ping on Mac: Pinging Websites, Domains, or IP Addresses
Ping is an essential utility for network administrators, but it’s also pretty handy to check if websites are online, how your internet connection is working, if you are experiencing lag or packet loss on a network connection, or to determine if a network resource is available.
Mac users can access and use ping to target any domain or IP address.
There are two ways to access ping tools in Mac OS from any Mac running any version of system software, but we’ll focus primarily on using ping from the command line since it is universal and works across platforms, meaning once you know how to use it on Mac OS X, but you’ll find it in Unix, Linux, and Windows too.
How to Use Ping from Mac OS X Command Line
Here’s how to use it the ping utility in all versions of Mac OS X from the Terminal app command line.
Ping a Destination IP or Domain Until Stopped
The most basic usage of ping will ping a destination until it is manually stopped, meaning there is no limit and no count.
- Launch the Terminal, found in the Utilities folder of Applications
- Type the following command:
- This will ping to yahoo.com repeatedly until you stop the ping command from running by hitting Control+C
ping yahoo.com
Ping an IP / Domain for a Specified Packet Count
Want to send a handful of packets and measure that instead of pinging endlessly until manually stopped? Use the -c flag attached to ping, everything else is the same:
- Go back to the command line if you’re not there again
- To send a specific number of packets to an address, modify ping syntax to use the -c flag like so:
- Hit return and let ping complete to the destination for the specified packet count before automatically terminating the ping
ping -c 5 192.168.0.1
In that example, -c 5 will send 5 packets to the destination IP.
Note the ping command only works if the Mac is online, and if the server you are pinging is online, and responds to ping requests. Most servers do respond if they’re online, except perhaps the most hardened networks who reject ping for security purposes.
Reading and Understanding Ping Results
An example of ping results may look like the following:
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=57 time=23.845 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=22.067 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=57 time=18.079 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=57 time=23.284 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=57 time=23.451 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=57 time=21.202 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=57 time=22.176 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=57 time=21.974 ms
^C
--- 8.8.8.8 ping statistics ---
8 packets transmitted, 8 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 18.079/22.010/23.845/1.703 ms
Each line to the destination represents a packet transission, the time specified in milliseconds at the end is most relevant for testing an internet connection as a high number there indicates there is lag or a connection problem. If there is no response at all, either the server is down, there is a connection problem, it does not respond to ping requests, or it is very slow to respond.
Perhaps next most useful is the “packet loss” number at the end. If packet loss is high, you almost certainly have network issues, because packet loss means that data being sent between you and the server is being lost (the term is quite literal in that sense). Troubleshooting packet loss can be challenging, but it can be the result of a poor internet connection, wi-fi problems, general network problems, a bad connection, a struggling connection, an interfered connection, connection interruptions, or many other potential networking issues.
Using ping to Verify Network Assets & Test Network Latency
I use ping constantly to make sure network servers are available, because it’s a lot faster to ping an IP than to try and connect to it through any number of protocols. It’s also a great way to test internet connections latency, which can be helpful for troubleshooting network issues with wi-fi or wired connections.
For users who do not feel comfortable with the command line, users can turn to the Network Utility app, which is bundled with every version of Mac OS X and provides a simple user friendly interface to ping, as well as a host of other helpful networking utilities.
This something very unique and helpful for me!! Thanks a lot. Everything explained in so simple way.
Control+C to stop ping
I find terminal to be much more useful than network utility for this reason: If you are pinging things, odds are something isn’t working right. If it’s not working right, you want to know where the problem is. So I open two terminal windows, one pinging my router and one pinging google. If the same problem exists between my mac and the router that exists between myself and google, i.e. dropped packets or wildly fluctuating ping times, I can focus on the local network. If the connection between my mac and the router is fine then I know either my internet provider’s connection is spotty or a piece of equipment further down the line needs to be reset..but troubleshooting the mac itself at that point would be fruitless.
Network Utility resolved my issue!
[…] Note: for whatever reason, when you are setting the IP address manually via the command line the Mac OS X Network Preferences doesn’t necessarily catch up to the changes. Do not be surprised if the Network preference pane is telling you that you “Airport does not have an IP address and cannot connect to the Internet.” when in fact, you do have one and you are online. You can verify that you are connected to the LAN or internet by using the ping command. […]
inket: What he said = easiest way.
Additional Information:
“Network Utility.app” provides a GUI version for Ping and other administration commands. (Traceroute, Lookup, whois etc.)