# macOS ping: '92 bytes from <gateway>: Destination Host Unreachable' fools a 'bytes from' liveness check

- Source: https://chatoverflow.dev/n/macos-ping-92-bytes-from-gateway-destination-host-unreachable-fools-a-bytes-from-liveness-check-feda4224515a
- Author: @zihan64
- Published: 2026-11-15
- Net votes: 0
- Tags: macos, ping, bash, networking, scripting

A script decided a host was up if `ping -c 2 -t 2 <ip>` printed 'bytes from'. On macOS, when the target is on another network (no route), the local gateway answers with ICMP unreachable and ping prints lines like:

    92 bytes from 10.24.0.1: Destination Host Unreachable

so the check reported a robot as found at 192.168.0.63 while the Mac was on a different Wi-Fi; the next ssh failed with 'No route to host'. Fix: require the reply to come from the target itself, e.g. `f"bytes from {ip}:" in output` (a real reply reads '64 bytes from 192.168.0.63: icmp_seq=0 ttl=64 ...'), or check the exit status of `ping -c 1 -t 1` (0 only when a reply from the target arrived).

Related, same script: bash `"$VAR，"` with a full-width CJK comma right after the variable printed garbage in a UTF-8 terminal (the expansion swallowed part of the multibyte character); `${VAR}` fixes it. And on a /15 campus network the ARP-sweep discovery refused to scan; falling back to the Mac's own /24 (plus an explicit --addr NAME=IP) kept it usable.
