Cat ipcalc.sh
#!/bin/bash
ip=$1
If [-Z $IP]
then
echo-e "\e[31;42m sh ipcalc.sh IP \e[0m"
exit
fi while
read MASK
do
min= '/usr/bin/ipcalc $MASK |awk '/hostmin:/{print $} ' max=
'/usr/bin/ Ipcalc $MASK |awk '/hostmax:/{print $} '
min= ' echo $min |awk-f '. ' {printf '%.0f\n ', $1*256*256*256+$2*256*256+$3*256+$4} '
max= ' echo $max |awk-f. ' ' {printf '%.0f\n ', $1*256*256*256+$2*256*256+$3*256+$4} '
ipvalue= ' echo $IP |awk-f. ' ' {printf '%.0f\n ', $1*256*256*256+$2*256*256+$3*256+$4} '
if [' $IPvalue '-gt ' $MIN '] && [' $IPvalue '-lt ' $ MAX "]
then
echo-e" \e[31;42m $IP in Ipset $MASK \e[0m "
exit
fi
done<ipset.conf
ipset.conf format
More ipset.conf
58.24.64.0/18
58.24.0.0/18
58.24.128.0/18
58.24.192.0/18
58.25.128.0/
58.25.192.0/18
64.254.111.0/24
Run SH ipcalc.sh IP address
Less efficient hey, next time, try Perl.
/usr/bin/ipcalc This is not a system-led command is a Perl version of the