Dup Ver Goto 📝

MassPing

PT2/linux/network does not exist
To
42 lines, 221 words, 1306 chars Page 'MassPing' does not exist.

If you want to quickly ping every address on a local network to see which are up machines:

localnet=0                                                   # e.g. 1 if your ips are 192.168.1.x
for s in $(seq 1 254); do 
  ( 
    # -w1 means 1 second deadline
    # -c1 means only one ping
    ping -w1 -c1 "192.168.$localnet.$s" 2>&1 >| "$s"
  )&    # & so pings are run in parallel
done

The & means all the pings will run in parallel. Do this in an empty directory in /tmp, e.g. /tmp/x12, then you will have a bunch of files. Then up machines reply, so you can

grep from *

whereupon you get

1:64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=17.2 ms
2:64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=257 ms
31:64 bytes from 192.168.1.31: icmp_seq=1 ttl=64 time=0.048 ms
37:64 bytes from 192.168.1.37: icmp_seq=1 ttl=64 time=942 ms
83:64 bytes from 192.168.1.83: icmp_seq=1 ttl=64 time=406 ms

which gives you the ip addresses of up machines on your LAN.

My current script

#!/bin/bash
localnet="${localnet-1}" 
for s in $(seq 1 254); do 
  ( 
    # -w1 means 1 second deadline
    # -c1 means only one ping
    ping -w1 -c1 "192.168.$localnet.$s" # 2>&1 >| "$s"
  )&    # & so pings are run in parallel
done

so that I can do

massping 2>&1 | grep from