ping
won't glob netmasks or wildcards.
You can flood ping the broadcast address of a subnet and monitor replies, though many routers will refuse to route ICMP over broadcast, because this is generally seens as abusive traffic. Additionally, only root can floodping with a zero interval.
For example:
ping -fb <BROADCAST ADDRESS>
Instead, you really ought to use NMAP in a friendly way.
ETA: if what you want is a list of node replies, we can get a little more clever:
ping -b -c 2 -i 20 <BROADCAST ADDRESS>
Where -b
permits pinging a broadcast address, -c 2
tells ping to send two pings, -i 20
tells ping to wait twenty seconds between them.
What this gets you is a near-instant list of replies with a twenty-second wait before termination, followed by traffic statistics. The reason to make two ping echo requests is because if you set -c 1
, ping will terminate on the very first response that it receives. We set twenty seconds between the two so that the list of replies is somewhat readable. It's a hack, but it works.
From here, you could suppress statistics output by piping to head -n-4
and then do useful awk
tricks, sort
, uniq
and the like to build a useful one-liner report.
ping
doesn't guarantee host-discovery, because hosts may ignore ping requests.nmap
is a much more reliable method, and is available for installation viaapt
- it may even already be installed on the system you're using. – James S. May 28 '14 at 20:13