You should use a combination of reverse and forward DNS lookups. Run a reverse DNS lookup on the accessing IP address to see if it resolves to a googlebot.com domain, then run a forward DNS lookup on that domain to verify it matches the original IP. Google also publishes a list of IP ranges that can be used for allowlisting.