Skip to Content
ZarexDocs

Unmask a fake Googlebot

Anyone can claim to be Googlebot. How to check that a request really comes from Google, by hand and then automatically.

Anyone can pretend to be Googlebot. A single command is enough:

curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://your-site.com

The User-Agent is a claim, not proof: it is a plain header that the client writes however it likes. This guide shows how to check that a request really comes from Google, first by hand, then automatically with Zarex.

Why it's a problem

Blocking Googlebot means disappearing from Google's results. So many sites give it special treatment: no rate limit, no CAPTCHA, sometimes access to subscriber-only pages so that they get indexed.

A scraper that wants to copy your prices, product pages or articles knows this. By claiming to be Googlebot, it hopes to benefit from those exceptions.

Checking by hand

Google documents two methods, usable without any special tool.

1. The two-way DNS check

First, ask for the name behind the IP address (reverse DNS):

nslookup 66.249.66.1
# Name: crawl-66-249-66-1.googlebot.com

The name must end with googlebot.com, google.com or googleusercontent.com. But that name is declared by whoever owns the address: an attacker who controls their server can write anything there. So you must check the other way round, by asking for the address of that name:

nslookup crawl-66-249-66-1.googlebot.com
# Address: 66.249.66.1

If you get the same address back, it really is Google: only Google controls the DNS of googlebot.com. This method is called "FCrDNS" (Forward-Confirmed reverse DNS).

2. The published IP ranges

Google publishes the list of its crawlers' addresses:

An address outside these ranges is not Googlebot, whatever its User-Agent. Bing, Apple, DuckDuckGo, OpenAI and Perplexity publish equivalent lists for their own crawlers.

The limits of checking by hand

  • DNS is too slow for every request. Two DNS lookups per bot visit add delay to the response, and a DNS server that doesn't answer leaves the question open. Should you then let the request through, at the risk of accepting an impostor, or block it, at the risk of blocking the real Google?
  • The lists change. They have to be downloaded and kept up to date.
  • Many bots publish nothing. The link-preview bots of Facebook, LinkedIn or X have neither an address list nor a verifiable DNS name.

With Zarex

Bot detection runs this check on every request:

  • Published ranges first, for Googlebot, Bingbot, Applebot, DuckDuckBot, GPTBot and PerplexityBot among others. The lists are built into Zarex and updated daily: no network call during the request. An address outside the ranges is denied, even if DNS is down.
  • Origin network for the link-preview bots of Facebook, X, LinkedIn and Telegram: they crawl from their operator's own networks, where nobody can rent a server.
  • DNS for the other bots that claim a domain.

1. Allow search engines, in observation mode

import { detectBot } from "@zarex/express"; // or your framework's package

rules: [detectBot({ mode: "DRY_RUN", allow: ["CATEGORY:SEARCH_ENGINE"] })],

Real search engines are allowed. Other bots, and impersonators, would be denied. In DRY_RUN, nothing is blocked yet: you first see what the rule would do.

2. Pretend to be Googlebot

From your own machine, your address is obviously not in Google's ranges:

curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" http://localhost:3000/

3. Read the decision

In the decision log, or in the rule's result in your code:

{
  "ruleType": "BOT_DETECTION",
  "verdict": "DENY",
  "dryRun": true,
  "reason": {
    "bot": true,
    "name": "Googlebot",
    "category": "CATEGORY:SEARCH_ENGINE",
    "verified": false,
    "method": "published_ranges",
    "reason": "identity claimed but IP outside the ranges published by the operator (spoofing)"
  }
}
  • verdict: "DENY" and dryRun: true: the rule would have denied the request, but it is in observation mode.
  • verified: false and method: "published_ranges": the claimed identity was compared with the ranges published by Google, and it doesn't match.

A real Googlebot gets verdict: "ALLOW" and verified: true instead.

4. Switch to LIVE

When the log looks right, remove mode: "DRY_RUN". The fake Googlebot then gets a 403 response, and the real one keeps indexing your site.

rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE"] })],

Bots that can't be verified

WhatsApp, Slack and Discord publish neither IP ranges nor a verifiable DNS name. If they are in allow, their User-Agent is enough, and the decision says so honestly: verified: false.

So don't grant them any privilege (paid content, pages behind a login): a script can claim to be WhatsApp as easily as Googlebot.

Key takeaways

  • The User-Agent says who the client claims to be, never who it is.
  • Verification is done on the IP address: published ranges, origin network, or two-way DNS check.
  • "Can't be verified" and "verified" must never be confused: read verified before granting a privilege.

Every option, category and verification method: Bot detection.

On this page