Fastest way to ping a network range and return responsive hosts?
Constraints:
1. Speed matters.
2. I am allowed to ping once.
I'm debating whether to use Python or shellscripting. Is there a method faster than bash
?
Here is the current code,
for ip in $(seq int1 int2); do
ping -c 1 xxx.xxx.xxx.$ip | grep "bytes from" &
done
Anything faster than this?
You should use NMAP:
nmap -T5 -sP 192.168.0.0-255
The following (evil) code runs more than TWICE as fast as the nmap method
for i in {1..254} ;do (ping 192.168.1.$i -c 1 -w 5 >/dev/null && echo "192.168.1.$i" &) ;done
takes around 10 seconds, where the standard nmap
nmap -sP 192.168.1.1-254
takes 25 seconds...