This script lists all country entries from the file ip2country. csv and displays the countries sorted for R80.10.
The country code can then be insert. For the selected country all IP Ranges are displayed.
So you can find all IP range, which are blocked by GeoProtection for a country.
Script:
#!/bin/bash
dec2ip() {
local ip dec=$@
delim=""
for e in {3..0}
do
((octet = dec / (256 ** e) ))
((dec -= octet * 256 ** e))
ip+=$delim$octet
delim=.
done
printf '%s' "$ip"
}
echo count CN country name
echo ----------------------------------------------------
more /opt/CPrt-R80/conf/ip2country.csv | awk '{print $6 " " $7} ' FS=',' | sort | uniq -c |sed 's/"//g'
read -p "Please insert country : " name
echo Find network with country : $name
if [ "$name" != "" ]
then
more /opt/CPrt-R80/conf/ip2country.csv |grep $name > _temp.txt
declare -i index
index=0
for i in $(cat _temp.txt ); do
ip123=$( echo $i |grep $name | awk '{print $1}' FS=',' |sed 's/"//g')
net123=$( echo $i |grep $name | awk '{print $2}' FS=',' |sed 's/"//g')
if [ "$ip123" != "" ]
then
# echo $ip123
index=$index+1
printf '%s' "$name $index # "
dec2ip $ip123
# echo $net123
printf '%s' " - "
dec2ip $net123
printf '%s\n' ""
fi
done;
fi
Version:
+ version 0.4 06-02-2018 - bug fix
+ version 0.5 09-03-2018 - bug fix
+ version 0.6 18-03-2018 - new feature
+ new version 0.9 06-04-2018 - new feature
➜ CCSM Elite, CCME, CCTE ➜ www.checkpoint.tips