Last active
April 3, 2025 06:59
-
-
Save kenzo0107/7d240e0e4938d342c919686021d653e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ips=( | |
66.249.71.9 | |
66.249.71.8 | |
66.249.71.7 | |
66.249.66.89 | |
66.249.66.88 | |
66.249.66.78 | |
66.249.66.69 | |
66.249.66.68 | |
) | |
for ip in "${ips[@]}"; do | |
echo "ip: $ip" | |
HOSTNAME=$(host "$ip" | awk '/domain name pointer/ {print $5}' | sed 's/\.$//') | |
echo "Resolved hostname: $HOSTNAME" | |
# check if the hostname belongs to googlebot.com or google.com | |
if [[ "$HOSTNAME" =~ .*\.google(bot)?\.com$ ]]; then | |
# get IP address from host name by forward lookup | |
REVERSED_IP=$(host "$HOSTNAME" | awk '/has address/ {print $4}') | |
# check if the forward lookup result matches the original IP | |
if [[ "$REVERSED_IP" == "$ip" ]]; then | |
echo "$ip is a verified Googlebot" | |
else | |
echo "$ip resolved to $HOSTNAME, but forward resolution does not match. Not a Googlebot." | |
exit 1 | |
fi | |
else | |
echo "$ip is NOT a Googlebot" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment