Expanding on A.B Answer - you can convert an entire list to CIDR notation using
for each in `cut -f2 -d":" ad | tr "-" ":"` ; do netmask $each 2>/dev/null; done
Or to IP/Netmask notation with
for each in `cut -f2 -d":" ad | tr "-" ":"` ; do netmask -s $each 2>/dev/null; done
So to push all the IP's from a particular range through a particular interface you could do somethhing like
Putting it together you could create a command with a script as below - removing the "echo" and finishing the iptables command as appropriate for your requirements:
#! /bin/bash
TMPFILE="/dev/shm/$$.del"
for each in `cut -f2 -d":" ad | tr "-" ":"`
do
netmask -s $each 2>/dev/null;
done > $TMPFILE
while read -r each
do
ROUTE=${each%/*}
NETMASK=${each#*/}
echo /sbin/route add $ROUTE netmask $NETMASK ....
done <$TMPFILE
2Why do you need to specify a range. The network address is obvious - 201.237.0.0/16. – Appleoddity – 2018-04-16T05:37:33.010
@Appleoddity Looking at a sample file (I took the first one - Andora) - its not as immediately obvious for a lot of ranges - of-course it can be worked out, but they have for example 194.158.64.0-194.158.95.255 - so a /19 – davidgo – 2018-04-16T07:02:11.540
That's right, the one provided was simply an example but some countries have hundreds of ranges. – hacktek – 2018-04-17T01:59:00.263