Skip to content

Instantly share code, notes, and snippets.

@wynemo
Created January 20, 2012 09:26
Show Gist options
  • Save wynemo/1646382 to your computer and use it in GitHub Desktop.
Save wynemo/1646382 to your computer and use it in GitHub Desktop.
ping ip range
#!/bin/bash
checkalive (){
NODE=$1
ping -c 3 $NODE>/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$NODE is alive"
else
echo "$NODE is not alive"
fi
}
input="$1"
ips=$(echo ${input%.*}.)
start=$(echo ${input##*.} | awk -F- '{print $1}')
end=$(echo ${input##*.} | awk -F- '{print $2}')
echo $start
echo $end
for(( i=$start;i<=$end;i++ ))
do
ip="$ips$i"
checkalive $ip
done
#检测ip ./ip1.sh 199.59.149.1-254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment