- Ping checks connectivity, latency, and packet loss with ICMP
- Key options: -c, -i, -s, -4/-6, -D, -W/-w for precise testing
- Traceroute/tracert displays the route and locates the problematic hop
- Diagnosing common errors and checking firewalls speeds up resolution
Mastering the ping command in Linux is one of those skills that makes all the difference when troubleshooting network problems. With ping, you can quickly check connectivity, latency, and availability before moving on to more complex diagnostics.
Furthermore, complementary tools like traceroute/tracert and hybrid utilities such as WinMTR provide a window into the path packets take. You'll learn how to use ping on Linux, Windows, and macOS, interpret output, adjust options, and troubleshoot common errors without wasting time.
What is ping and what is it for?
Ping is a diagnostic utility that sends ICMP ECHO_REQUEST packets to a destination (IP address, host, or domain) and waits for an ECHO_REPLY. It uses the TCP/IP model and its layers to understand which layer ICMP operates at. If there is a response, the host is reachable, and the round-trip time (RTT) is measured . It also reports the packet size in bytes, the time to live (TTL), and packet loss.
In practice, ping is used daily to validate connectivity, estimate latency, confirm server availability, and rule out basic network problems. It's the first step in detecting outages, congestion, or problematic routes before further analysis.
How ping works and what exactly it measures
When you ping a destination, the tool sends a series of ICMP packets and displays the response for each one. Typical output fields include bytes, responding host, icmp_seq, TTL, and time in ms , as well as a final statistics block.
Example response line: 64 bytes from 185.185.185.185: icmp_seq=1 ttl=64 time=0.1 ms . Here you can see the usable size (56 bytes + 8 bytes ICMP header = 64), sequence number, packet lifetime, and RTT. The final statistics aggregate transmitted, received, loss, and RTT min/avg/max/mdev.
When to use ping
Ping is useful in many everyday scenarios. Check if your website or online store is responding, if a VPS is up and running, or if a device on your Wi-Fi is still connected . It also helps you identify slowness: high latency or packet loss indicates network congestion or routing issues.
Even if everything seems fine, running pings occasionally helps detect underlying issues. Establishing a latency baseline allows you to identify deviations following network changes or traffic spikes.
Difference between ping and traceroute/tracert
While ping answers the classic question 'Does it arrive and how long does it take?', traceroute (tracert on Windows) answers 'Where does it go?'. Traceroute reveals each intermediate hop and its time to the destination, key to finding where a loss or bottleneck occurs.
Combining them is ideal: if ping shows signal loss, traceroute tells you the exact hop where the problem starts. If you want to combine both perspectives into a single tool on Windows, WinMTR is a great option.
How to ping in Windows
On Windows, open Command Prompt (search 'cmd') and run the command. The basic form is: ping destination (IP, host, or domain). By default, it sends 4 packets and displays statistics.
ping 8.8.8.8
ping google.com
For common Windows options: -n defines the echo number, -l the packet size, -w the timeout in ms, and -i the TTL . Example for 10 packets of 1400 bytes:
ping -n 10 -l 1400 google.com
How to ping on macOS
On macOS, open Terminal (Applications > Utilities > Terminal) or use Spotlight. Type: ping target and finish with CTRL + C to see the summary.
ping 8.8.4.4
ping google.com
You can also use the older Network Utility in versions that include it. Keep in mind that macOS shares much of its syntax with Linux , and many options are the same.
How to ping in Linux
On Linux, open the terminal (for example, with CTRL + ALT + T) and run the command. Ping will run continuously until you press CTRL + C , after which you will see the statistics block.
ping 1.1.1.1
ping localhost
If you need to check if ping is installed or its version, you can do so directly. On Ubuntu/Debian, the usual package is iputils-ping.
ping -V
sudo apt-get update && sudo apt-get install -y iputils-ping
General syntax and essential options
The generic form is: ping destination . The destination can be an IP address, a hostname, or a domain; if you use a domain, it will resolve via DNS.
- -c N (Linux/macOS): Limits the number of packages. Useful to prevent the test from running.
- -a (Linux/macOS/Windows): Audible ping; beeps once for each response, very useful for background diagnostics.
- -i SEG (Linux/macOS): Interval between packets in seconds; decimals supported. Requires privileges for less than 0.2 s.
- -q (Linux/macOS): Silent output; only displays the statistical summary.
- -4 / -6 (Linux/macOS): Force IPv4 or IPv6 respectively. On systems that split binaries, ping6 is the IPv6 variant..
- -s BYTES (Linux/macOS): ICMP payload size. Default: 56 bytes (84 bytes including IP+ICMP headers, 28 bytes overhead).
- -D (Linux/macOS): Add UNIX-like timestamp at the beginning of each line.
- -W SEG (Linux/macOS): Maximum wait time per echo response; if exceeded, it is considered timed out.
- -w SEG (Linux/macOS): Total test time before automatically ending.
Lesser-known advanced options
For fine diagnostics, ping offers a good range of flags. These options help you adjust routing, buffers, MTU, labeling, and information visibility:
- -A: Adaptive ping (adjusts the rate based on responses).
- -b: allows pinging broadcast addresses.
- -B: Do not modify the source address of the probes.
- -d: Enable SO_DEBUG on the socket.
- -F flow label (IPv6): Assigns a 20-bit hex flow label to echo requests.
- -h: displays quick help.
- -I interface: sets the output interface. Very useful on computers with multiple NICs.
- -l preload: Sends several initial packets without waiting for a response (high values require privileges).
- -L: Blocks multicast loopback.
- -m mark: Label outgoing packets (useful for routing policies).
- -M pmtudisc_opt: Controls the Path MTU Discovery strategy. With -M and -s appropriate the effective MTU is detected.
- -N nodeinfo (IPv6): Node information options.
- -n: numeric output; avoids resolving names.
- -O: Reports pending responses before the next submission.
- -p pattern: Pads the payload with a pattern (up to 16 bytes) to detect data-dependent problems.
- -What cough: defines TOS/DSCP.
- -r: Ignores the normal routing table; forwards directly out an adjacent interface.
- -R: record route (limited by intermediate support).
- -S sndbuf: size of the socket send buffer.
- -t ttl (Linux): Defines the IP TTL. On Windows the TTL is set with -i.
- -T: special IP timestamp options (tsonly, tsandaddr, tsprespec).
- -U: Shows the total user-to-user latency, not just network latency.
- -v: detailed output; -V shows the version.
Case studies: from basic to advanced
Checking general internet connectivity and resolving names is the first step. You can alternate between pinging domains and IP addresses to isolate DNS problems.
ping google.com
ping 8.8.8.8
Checking the local stack saves you time: if this fails, the problem is on your own computer , not the external network.
ping localhost
ping 127.0.0.1
ping 0
Validating the specific interface is also common in networks with multiple NICs. Forcing the outgoing interface clarifies routes and tables.
ping -I enp7s0 1.1.1.1
Limiting the number of packages for quick tests or scripts is a classic. -c defines the count and -q reduces noise while leaving a clear summary.
ping -c 5 -q 9.9.9.9
Adjusting the interval gives you more samples in less time or reduces the load. Below 0.2 seconds on Linux, you need privileges.
ping -i 3 31.13.90.36
sudo ping -i 0.1 31.13.90.36
Testing different packet sizes detects MTU or fragmentation problems. Remember that the theoretical maximum IP packet size is 65.535 bytes, including headers.
ping -s 1000 8.8.4.4
ping -M do -s 1472 google.com
Timestamps make it easier to correlate spikes with events. -D adds the UNIX stamp to each line of response.
ping -D cloudflare.com
Interpret the output and statistics
Each line of response reflects a single measurement; the final block summarizes the series. Pay particular attention to packet loss, minimum/average/maximum RTT, mean development time (MDDT), and timing consistency to assess stability.
--- destino ping statistics ---
X packets transmitted, Y received, Z% packet loss
rtt min/avg/max/mdev = A/B/C/D ms
Establish a baseline: repeatedly ping under normal conditions and save the usual average. If the average latency or mdev later increases, something has changed in your network (load, routing, saturation, or degradation).
Common errors and how to diagnose them
If there is no response and the timeout does not expire, the host may discard ICMP. Some servers and CDNs block echoes as a matter of policy , which does not necessarily mean the service will go down.
The 'destination host unreachable' message can come from your computer or an intermediate router. If it's issued by your host, there's no route; if it's from a remote hop, the external network has no path to the destination.
'Request timed out' means the request was sent but the response didn't arrive. This can be due to intermediate loss, filtering, or route asymmetries . In these cases, use traceroute to locate the problematic hop.
If you're using a firewall, check the rules. On Linux, DROP/REJECT rules over ICMP will prevent sending or receiving echoes , making it appear as if everything is down.
sudo iptables -L
# Localiza reglas sobre ICMP con DROP/REJECT
# Ajusta o elimina si procede (ejemplo genérico):
sudo iptables -D RULE_SPECIFICA
Ping on mobile devices
Android and iOS do not include a native ping function accessible from the standard interface. The easiest way is to use dedicated apps for quick, on-the-go testing.
On Android, options like 'Ping & Net' work well; on iOS, 'Network Ping Lite' is a reliable option. Avoid rooting or jailbreaking just for ping; a trustworthy app is sufficient . Check ratings and permissions before installing.
Traceroute and tracert: view the path of packets
Traceroute on Linux and macOS, and tracert on Windows, show every hop from your computer to the destination. Each line indicates the intermediate router and the time of each attempt . If you see asterisks after a certain point, the route is truncated or filtered.
# Windows
tracert ejemplo.com
# macOS/Linux
traceroute ejemplo.com
In classic macOS, you can use Network Utility if available, with a dedicated traceroute tab. In server environments, the Terminal will be your primary tool.
Continuous monitoring with WinMTR
WinMTR combines ping and traceroute on Windows to show route stability over time. Enter the host or IP address, run the test for about 10-15 minutes, and copy the report for analysis or technical support.
1) Descarga WinMTR (proyecto en SourceForge)
2) Field 'Host': escribe dominio o IP
3) Start y deja correr ~15 minutos
4) Usa 'Copy Text to clipboard' para compartir el resultado
Good practices and usage tips
Point to multiple destinations to isolate the problem: your gateway, a well-known DNS server, and the final host. Comparing the results will reveal whether the fault is internal, with the carrier, or at the destination.
Avoid overusing flood mode except in controlled tests. -f sends packets at maximum speed and can simulate traffic spikes ; use it with permission and clear criteria.
sudo ping -f destino
It combines tools for a complete view. Traceroute locates the problematic hop; iperf measures bandwidth; Wireshark allows deep packet inspection when you need to get into the details.
In IPv6-enabled environments, validate both protocols. Force -4 or -6 as appropriate to rule out preference or dual-stack resolution issues.
Options and peculiarities in Windows, macOS and Linux
The flags vary between systems. On Linux/macOS, -c limits packets, -i range, -s size, and -t TTL . On Windows, -n, -l, -wy, and -i serve similar roles (with differences in units and scope).
Useful examples for each system: Windows: ping -n 4 -l 1200 domain; Linux/macOS: ping -c 4 -s 1200 domain . Consult your local help if you are unsure of the exact syntax.
# Linux/macOS
ping -c 4 -s 1200 google.com
ping -4 google.com
ping -6 google.com
# Windows
ping -n 4 -l 1200 google.com
DNS checks and name resolution
Pinging a domain validates whether the DNS resolves correctly. When the domain resolves, you'll see the target IP address in the output header; if resolution fails, check your DNS settings or hosts file.
Use complementary tools like nslookup to verify logs. Ping checks reachability; nslookup gives you the DNS data that explains an unexpected resolution.
nslookup ejemplo.com
Security, protocol limits and MTU
Some devices block ICMP as a matter of policy or to prevent abuse. Don't assume a service outage simply because there are no ping responses ; check via TCP/HTTP or with the service's own tools.
Remember that the default payload in Linux is 56 bytes; with headers, the total rises to 84. The IP packet limit is 65.535 bytes including headers , hence the usable size of -s must take into account the overhead.
To measure path MTU without fragmentation, combine the DF/PMTUD with increasing size. With -M and -s adjusted, you'll see where it starts to fail due to insufficient MTU.
ping -M do -s 1472 ejemplo.com
Quick FAQ
What exactly does ping check? IP connectivity and round-trip time via ICMP, reporting loss and latency.
Why does a domain sometimes not respond to ping? Because many servers filter ICMP. The web service may still be operational.
How do I shorten ping on Linux and macOS? With CTRL + C; at that moment the summary statistics are printed.
Can you use ping with IPv6? Yes, with -6, or with ping6 on systems that separate it. You'll see IPv6 addresses and routes.
Does ping work on mobile devices? Yes, using dedicated apps. Avoid unnecessary root/jailbreaking and use reputable options.
You have a solid guide to go from basic to advanced with ping: you can validate local and remote connectivity, adjust intervals and sizes, diagnose losses, understand routes with traceroute, and document findings with WinMTR . A methodical use of these tools saves you hours of blind testing and allows you to act precisely in the face of any network issue.