用 ping -c 测试网络连通性

只发 5 个测试包,快速确认 Mac 能否连上某个网站以及延迟多少。

macOSping 连通测试网络诊断低风险
运行 ping -c 5 example.com,发送 5 个测试包后即可查看响应时间和丢包率统计。

01命令

命令
$ ping -c 5 example.com

02作用说明

ping 会向目标主机发送小的 ICMP 回显包并测量响应耗时;-c 5 表示发满 5 个包就停止并输出丢包和延迟统计,不像 macOS 默认那样一直发个不停。建议分段排查:先 ping 路由器地址(通常是 192.168.1.1)测试本地 Wi-Fi,再 ping 8.8.8.8 测试外网,最后 ping 网址——如果 IP 能通而域名不通,问题就出在 DNS。

03风险

风险低风险
!注意: 很多服务器会屏蔽或限制 ping,收不到回复不一定代表网站挂了——先换一个目标再下结论。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • ping - Send ICMP ECHO_REQUEST to network hosts
    SS64 · technical · 2026-09-17
    依据: Documents the -c option as 'count', i.e. stop after sending (and receiving) that many ECHO_RESPONSE packets.
  • PING(8) - macOS manual page
    Apple (Xcode man pages mirror) · vendor-doc · 2026-09-17
    依据: The manual page describes ping as sending ICMP ECHO_REQUEST packets and documents -c count to stop after that many replies.

最后验证: 2026-09-19 · 分类: 网络

06相关方案