Tag: /24

Ping a complete /24 subnet with one bash line

if you need to know what devices are currently connected on the same network as you ,
there is no very simple way ,

you could use the command arp -a to see your arp table but it’s not always up to date and can have false entries.

using the broadcast option is never working for me ,  nmap is slow and only show the results when the scan il finished and it’s not installed by default on most distrib.

Most ping loop to cycle through all available address on the network are going to deal with the high minimum timeout time of 1 second before trying the next address.
the Best solution is to launch the ping command in parallel , you could use xarg -P to do that , but xargs is not present on lightweight linux distribs like OpenWRT.

 

using that command , you will launch in parallel 255 time the program ping , ping an address from 192.168.1.1 to 192.168.1.254 with only one paquet and a timeout of 1 second.

for i in $(seq 254); do ping 192.168.1.$i -c1 -W1 & done | grep from

the answer you will get will look like that

this loop use only very simple commands included in most linux operating systems