ping - macOS
Overview
ping is a network utility that sends echo requests to a specified host to determine if it is reachable and to measure the time it takes for packets to travel between hosts.
Syntax
ping [options] <destination-address> [duration]
Options/Flags
- -a: Resolve the hostname to an IP address
 - -c : Number of echo requests to send (default: 10)
 - -i : Time between echo requests in milliseconds (default: 1000)
 - -s : Size of the echo request in bytes (default: 56)
 - -t: Send echo requests indefinitely
 - -v: Verbose output
 - -w : Maximum time to wait for a response in milliseconds (default: 1000)
 
Examples
- Simple usage: Ping Google’s DNS server
 
ping 8.8.8.8
- Specify request count and interval: Send 5 echo requests with a 500ms interval
 
ping -c 5 -i 500 google.com
- Resolve hostname to IP address: Ping a website by its hostname
 
ping -a stackoverflow.com
- Indefinite ping: Keep sending echo requests until stopped
 
ping -t stackoverflow.com
Common Issues
- Destination unreachable: The host is not reachable, or the network is experiencing problems.
 - Request timed out: The host did not respond within the timeout specified.
 - High latency: The response time is unusually high, indicating network congestion or other issues.
 
Integration
ping can be integrated with other commands for advanced tasks:
- Traceroute: Trace the path of packets to a host
 
traceroute `ping -a <destination-address>`
- Port scanning: Check if a specific port is open on a host
 
nc -w 1 -z `ping -a <destination-address>` <port-number>
Related Commands
- traceroute: Trace the path of packets to a host
 - nc: Network utility for testing network connectivity
 - nslookup: Lookup DNS information about a host