14 lines
311 B
Bash
14 lines
311 B
Bash
|
#!/bin/bash
|
||
|
# ping-scan subnet without other fancy tools
|
||
|
for i in $1.{1..255}
|
||
|
do
|
||
|
if
|
||
|
ping -c 1 -W 1 $i >/dev/null
|
||
|
then
|
||
|
echo "$i: online, hostname: $(host $i | cut -d " " -f 5)"
|
||
|
else
|
||
|
[[ $2 = offlinealso ]] && echo "$i: offline, hostname: $(host $i | cut -d " " -f 5)"
|
||
|
fi
|
||
|
done
|
||
|
exit 0
|