Affiliate Disclosure
If you buy through our links, we may get a commission. Read our ethics policy.

How to test your network or server using ping in Terminal

The UNIX ping command lets you test network servers and latency. Here's how to use it in the macOS Terminal app.

The UNIX ping command is a tiny UNIX network tool that allows you to test your network, that of your ISP or organization, remote servers, and network latency.

ping is one of the oldest and simplest UNIX commands and is available in virtually all UNIX distributions, including macOS.

ping was written by the late Mike Muuss in 1983 at the US Army Defense Ballistics Lab. Sadly, Muuss died young in 2000 at the age of 42, in a car accident on Interstate 95 in Maryland.

Muuss was also the author of several 3D/CAD apps at the time, as well as the UNIX utility ttcp which measures network throughput using TCP and UDP protocols. Muuss' original technical web page is still available on one of the first fifty servers on the internet: a US Army FTP server for the Ballistics Lab.

The ping command works by using the Internet Control Message Protocol (ICMP) - in particular by sending ECHO_REQUEST packets, and by utilizing its Time To Live (TTL), latency, and packet loss detection to measure round trip hops to a given internet-connected computer at either an IP address or domain name.

Don't confuse Time To Live with a different subject from electronics: Transistor-to-transistor Logic (also abbreviated 'TTL').

The name "ping" comes from submarine SONAR technology which detects underwater vessels by emitting sound waves, and then measuring the time it takes for echoes to return.

With ping you can detect if your network is working, hops in between your computer and the destination, round-trip times, and whether a given computer is online or not.

You can also use ping to look for general network and packet errors.

Using ping on macOS

To use ping on macOS, open the Terminal application in your Startup Disk's /Applications/Utilities folder, then type the ping command followed by a space, then an IP address or domain name. Press Return on your keyboard to start the command.

For example, you can ping Apple itself in Terminal with:

ping apple.com and pressing Return.

If your computer has a working internet connection you'll see ping begin its tests, which will keep running until you stop it by pressing Command-Z on your keyboard (unless you specified the -c (count) option with the command).

In Terminal you can test remote servers and connection times using ping. Using ping to test apple.com.

When you use ping, you can specify either the IP address of the target computer or a domain name. If you use a domain, ping will use DNS to resolve the domain name to that domain's default server (or to a gateway or CDN that points to the default server).

There is also an IPv6-enabled version of ping called ping6 which is also available on macOS.

Options

ping has several dozen options. To see them type:

man ping in Terminal and press Return.

Options include (but are not limited to):

  1. Audible bell (for failures)
  2. Test count
  3. Wait times
  4. Type of network service
  5. TTL
  6. A source address
  7. Packet size
  8. Packet flooding
  9. Recording of routes
  10. Remote netmask printing
  11. Bypass routing tables
  12. Quiet or verbose mode (for error messages)
  13. SO_DEBUG flag (for recording)

Apple also provides a few more options found only in the macOS version of ping including:

    Network interface to bind Prohibiting cellular interfaces Receive timestamp

See the man page in Terminal for full options.

You can also ping your own computer's network interface to see if the device is working properly or not.

If any duplicate or damaged packets are detected, ping will display those too.

Default ping results displayed in Terminal for each test show:

    Bytes received IP of responder TTL Round trip time (in ms) Packet sequence number

If you didn't specify the number of tests to run using the -c flag, press Command-Z on your keyboard to end the tests.

ping is a quick and easy way to conduct network tests on your own network, your Mac, and on remote machines. Once you know how it works, you'll find yourself using it all the time.



4 Comments

mfryd 16 Years · 231 comments

If you didn't specify the number of tests to run using the -c flag, press Control-C on your keyboard to end the tests.

DAalseth 6 Years · 3070 comments

I use ping quite a bit, whenever the network seems funky. You also can ping IP addresses directly or a URL, which is nice. My standard form is to ping the border router at the University I used to work at, it’s across the continent and I know the address by heart even after all these years. Then ping a standard URL, google, apple, my local ISP, CNN, someone like that. If those look OK then I’ll ping the service I’m having trouble with, like the remote system I log into. It’s not uncommon that I’ll have tech support on the line, and they’re saying to restart my router or it’s a local problem with my ISP. Then I’ll send them screenshots of my pings showing everything is good locally, and nationwide and the slowdown starts at their border. I get put on hold, they come back and say try it again and it’s fine. 

dewme 10 Years · 5780 comments

The Net Analyzer app for iOS and iPadOS includes the Ping feature among other useful network probing utilities like Port scanner and Whois. It also has a WiFi network scanner that supports IPV4 and IPV6, speed tester, etc. Nice little utility, especially for folks who are less Unix command line aware. But yeah, the Terminal has always been something that I’ve depended on.

softeky 17 Years · 138 comments

Muuss… my hero (RIP). Ping plus traceroute were *NIX network diagnostic apps I relied on to find network faults. I would run ping in parallel on multiple windows with each ping targeted at a different traceroute host on the way to a target. This would pinpoint a connection fault even if the fault was intermittent. More recently poor WiFi locations could be diagnosed by walking around while pinging (menu-bar WiFi strength meters have been made useless long ago, but ping packet throughput measure is instant). Then along came “mtr” https://www.tecmint.com/mtr-a-network-diagnostic-tool-for-linux/ (works on most *NIX). When run as super-user, mtr combines ping with traceroute and does the job all in one terminal window.

Mtr source: https://github.com/traviscross/mtr