howto: scan network for all active hosts
Thursday, June 18, 2009, 06:35 AM -
LinuxPosted by Administrator
I needed a command or script to scan the whole network for all active hosts/devices. Ok, a broadcast ping will do something like this but you should have enabled on the hosts to answer on broadcast pings (default not under Debian Linux).
So I tried a lot of things and this is the best solution for me. This command will give you a list for all active hosts.
for ip in $(seq 1 254); do ping -c 1 192.168.0.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.0.$ip UP" || : ; done
For using this on your network you only have to change the following values.
$(seq 1 254) 1.....start IP
254...end IP
192.168.0.$ip IP of network (e.g. 172.16.1.$ip)
Have a funny scanning ;-)