Skip to content
shellmap

pingSend ICMP echo requests to test reachability and round-trip latency across all 5 shells

Equivalents in every shell

Bashunix
ping example.com
Zshunix
ping example.com
Fishunix
ping example.com
PowerShellwindows
Test-Connection example.com

Aliased as `ping` in PowerShell 7+ via `tnc` or the real `ping.exe`. `Test-Connection` returns objects.

cmd.exewindows
ping example.com

Defaults to 4 packets then exits. Use `-t` to ping continuously.

Worked examples

Send 5 packets then stop

Bash
ping -c 5 example.com
PowerShell
Test-Connection example.com -Count 5
cmd.exe
ping -n 5 example.com

Ping continuously until interrupted

Bash
ping example.com
PowerShell
Test-Connection example.com -Continuous
cmd.exe
ping -t example.com

Test TCP port reachability (not ICMP)

Bash
nc -zv example.com 443
PowerShell
Test-NetConnection example.com -Port 443
cmd.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

Related commands