I'm trying to write a bash script that's supposed to perform reverse DNS lookup on a range of IP addresses. The idea is to provide the network (first 3 octets) as $1, the start of the range to be checked as $2 and the end of said range as $3.
So I ended up with:
#!/bin/bash
if [ $# -ne 3 ]
then
echo "[*] Usage: reverselookup.sh [Network (x.x.x)] [start of range (y)] [end of range (z)]"
exit 1
fi
for ip in {$2..$3}
do
host $1.$ip | grep pointer
done
Now I thought that this would use the normal sequence operation in bash for loops, like in
for i in {2..5}
gives you a loop with 2, 3, 4 and 5. However it doesn't work.
If I echo the $ip inside the loop and run it as e.g.
reverselookup.sh 192.168.10 21 50
it presents me with
{21..50}
Does anyone know whether it's possible to make this work? Or do I have to rethink my appraoch?
Thanks in advance.