TECH

How to check your network or server using ping in terminal

Terminal for macOS

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 small UNIX networking tool that allows you to test your network, your ISP or organization's network, remote servers, and network latency.

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

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

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

The ping command works by using the Internet Control Message Protocol (ICMP), specifically sending ECHO_REQUEST packets and using its time-to-live (TTL), latency, and packet loss detection to measure round-trip hops to a given Internet-connected computer by IP address or domain name.

Don't confuse time to live with another electronics concept: transistor-transistor logic (also abbreviated “TTL”).

The name “ping” comes from underwater sonar technology that detects underwater vessels by emitting sound waves and then measuring the time it takes for the echo to return.

With ping, you can determine whether your network is working, the round-trip times between your computer and the destination, and whether the computer is online or offline.

You can also use ping to find common network and packet errors.

Using ping on macOS

To use ping on macOS, open the Terminal app in the /Applications/Utilities folder on your startup disk, then type the ping command followed by a space, then the IP address or domain name. Click Return on your keyboard to run the command.

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

ping apple.com and press Return.

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

Using ping to test apple.com.

When using 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 pointing 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 a terminal and press Return.

Features include (but are not limited to):

  1. Ring tone (for failures)
  2. Number of tests
  3. Timeout
  4. Network service type
  5. TTL
  6. Source address
  7. Packet size
  8. Packet flooding
  9. Log routes
  10. Remote netmask printing
  11. Routing table traversal
  12. Quiet or verbose mode (for error messages)
  13. SO_DEBUG flag (for logging)

Apple also provides several additional options that are only found in the macOS version of ping, including:

    Network interface to bind to Disable cellular interfaces Get a timestamp

See the Terminal man page for a full list of options.

You can also ping your computer's network interface to check if the device is functioning properly.

If any duplicate or corrupted packets are found, ping will display them as well.

The default ping results displayed in Terminal for each test show:

    Bytes Received Responder IP Address TTL Round Trip Time (ms) Packet Sequence Number

If you did not specify the number of tests to run using the -c flag, press Command-Z on your keyboard to terminate the tests.

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

Follow AppleInsider on Google News

Leave a Reply