在 macOS 上用 ping 测试网络连通性与延迟
发送固定次数的 ICMP 探测包,读取往返时间统计和丢包率。
运行 ping -c 4 example.com 发送 4 个探测包并查看往返时间汇总与丢包率。
01命令
命令
$ ping -c 4 example.com02作用说明
不加 -c 时 macOS 的 ping 会一直运行直到按 Ctrl-C,适合持续观察;快速排查时用 -c 4 得到简洁结果即可。末尾统计显示往返时间的最小/平均/最大/标准差和丢包率——丢包超过几个百分点或波动很大,通常指向 Wi-Fi 信号问题、链路拥塞或对端服务器不稳定。改用 IP 地址(如 ping -c 4 1.1.1.1)可以把 DNS 故障和网络连通性问题区分开。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- ping - Send ICMP ECHO_REQUEST packets to network hosts依据: Documents `-c count` to stop after N packets and `-i wait` for the interval, with usage examples like `ping -i 5 example.com` and round-trip time statistics.
- ping(8) man page依据: Man page for ping: `-c count` stops after sending count ECHO_REQUEST packets and prints a summary of round-trip times, packet loss and `-i wait` interval control.
最后验证: 2026-09-19 · 分类: 网络