ping — Send ICMP echo requests to test reachability and round-trip latency across all 5 shells
Equivalents in every shell
Bashunix
ping example.comZshunix
ping example.comFishunix
ping example.comPowerShellwindows
Test-Connection example.comAliased as `ping` in PowerShell 7+ via `tnc` or the real `ping.exe`. `Test-Connection` returns objects.
Worked examples
Send 5 packets then stop
Bash
ping -c 5 example.comPowerShell
Test-Connection example.com -Count 5cmd.exe
ping -n 5 example.comPing continuously until interrupted
Bash
ping example.comPowerShell
Test-Connection example.com -Continuouscmd.exe
ping -t example.comTest TCP port reachability (not ICMP)
Bash
nc -zv example.com 443PowerShell
Test-NetConnection example.com -Port 443cmd.exe
powershell -Command "Test-NetConnection example.com -Port 443"Gotchas
- Unix `ping` runs forever by default and needs `-c N` to stop; Windows `ping` sends 4 packets unless you pass `-t`.
- Many cloud providers and firewalls drop ICMP — `ping` failing doesn’t mean the host is down. Use `Test-NetConnection -Port` or `nc -zv` to check TCP reachability.
- Raw ICMP requires elevated privileges on some Linux distros (setuid bit on the binary or `CAP_NET_RAW`); plain users may get permission errors.
WSL & PowerShell Core notes
pwsh`Test-Connection` is cross-platform on pwsh 7+ (Windows, Linux, macOS) and is the recommended portable form — it returns objects, supports `-Count` / `-Continuous` like Unix `ping -c` / endless mode, and shells out to the platform's native ICMP under the hood. On Linux pwsh hosts that means the system `ping` binary is invoked, so `CAP_NET_RAW` / setuid rules still apply. For TCP-reachability checks when ICMP is firewalled, use `Test-Connection -TcpPort 443 example.com` (pwsh 7+) instead of plain `Test-Connection`.
WSLWSL2 ICMP is namespaced to the WSL VM: `ping example.com` works (NAT routes outbound), but `ping <windows-host-ip>` only succeeds if Windows Firewall has the inbound ICMP echo rule enabled, which is OFF by default on private networks. To ping the WSL2 VM from Windows, you need its dynamic VM IP (`wsl hostname -I`) — `ping wsl.localhost` does not work in NAT mode. On Windows 11 24H2 with mirrored networking, both namespaces share, so `ping 127.0.0.1` reaches the same loopback from both sides. ICMP from inside WSL may need `sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"` on some distros (Alpine, minimal Debian) where the unprivileged ping range starts empty.
Common tasks using ping
- Get the MAC address of a network interface
Print the hardware (link-layer) address of one or all network interfaces — for license-binding, WoL setup, DHCP reservation matching, inventory audits, or diagnosing why a switch port shows an unexpected device.
- Test if a network port is open
Check whether a remote (or local) TCP port is accepting connections — for service health checks, firewall debugging, or pre-flight validation in scripts.
- Traceroute to a host
Map the network path to a destination — for diagnosing latency spikes, ISP-level routing problems, and "where exactly is this packet getting dropped".