Recently I wanted to check if the IPs ( I had around 45) belonged to google bot. One option was to run host <ip> and host <domain name> for each of the IPs, but this was practically not possible and if possible it would be time consuming. So I came up with a simple shell script to do this job.
Let the IPs be in the file googlebots, for example let us add these IPs:
18.104.22.168 22.214.171.124 126.96.36.199
The shell script is given below:
#!/bin/sh file="googlebots" while read -r line do hostName=`host $line | cut -d" " -f 5` domainName=`echo $hostName | cut -d"." -f2,3` #echo $domainName #echo "$hostName" hostIp=`host $hostName | cut -d" " -f 4` #echo "$hostIp" if [ $line == $hostIp ] && [ $domainName == "googlebot.com" ] then echo "Googlebot: $hostIp -> $hostName" fi done < "$file"