# 在服务器日志中验证 AI 爬虫流量

> user-agent 可以伪造，只统计验证过的请求。Google 和百度用反向 DNS 查询验证。OpenAI、Perplexity、Anthropic 公布了 IP 列表，按 IP 段对照即可。

- URL: https://geo.casa/zh-cn/implementation/verify-ai-crawlers/
- 指南 · 官方文档已说明
- 审核于: 2026-10-25

## 开始之前

- 能拿到服务器或 CDN 的原始日志，其中包含每个请求的客户端 IP 和 user-agent。
- 有可以做 DNS 查询的 shell（`host` 或 `dig`），或者能获取 JSON 并按 CIDR 匹配 IP 的脚本。

## 1. Google：先反向、再正向 DNS 查询

> **官方文档已说明:**
> 对日志中的 IP 做反向 DNS 查询，确认域名是 `googlebot.com`、`google.com` 或 `googleusercontent.com`。再对这个域名做正向 DNS 查询，确认它解析回同一个 IP。大规模检查时，Google 建议改为对照其公布的 IP 列表。
>
> 参考来源: [Google: Verify requests from Google crawlers and fetchers](https://developers.google.com/crawling/docs/crawlers-fetchers/verify-google-requests)

```sh
host 66.249.66.1                              # → crawl-66-249-66-1.googlebot.com
host crawl-66-249-66-1.googlebot.com          # → 66.249.66.1（必须一致）
```

Google 按爬虫类别以 JSON 文件公布 IP 列表，分为常规爬虫、特殊用途爬虫、用户触发的抓取工具。链接在其验证说明页上。

## 2. OpenAI 和 Perplexity：公布的 IP 段

> **官方文档已说明:**
> OpenAI 以 JSON 公布每个爬虫的 IP 地址：
>
> `openai.com/searchbot.json`（OAI-SearchBot）、`openai.com/gptbot.json`（GPTBot）和 `openai.com/chatgpt-user.json`（ChatGPT-User）。
>
> 参考来源: [OpenAI: Overview of OpenAI crawlers](https://developers.openai.com/api/docs/bots)

> **官方文档已说明:**
> Perplexity 为 PerplexityBot 公布了 `www.perplexity.com/perplexitybot.json`，为 Perplexity-User 公布了 `www.perplexity.com/perplexity-user.json`。
>
> 参考来源: [Perplexity: Perplexity crawlers](https://docs.perplexity.ai/docs/resources/perplexity-crawlers)

每个文件列出若干 CIDR 前缀。请求要同时满足两点才算验证通过：user-agent 写明是该爬虫，**并且** IP 落在该爬虫的某个前缀内。

## 3. Anthropic

> **官方文档已说明:**
> Anthropic 在爬虫帮助文章中链接了爬虫使用的 IP 列表。来源 IP 在列表中，说明爬虫来自 Anthropic。
>
> 它同时提醒，按 IP 屏蔽「可能无法正常生效，也无法持续保证退出」，因为爬虫会读不到 robots.txt。退出应使用 robots.txt。
>
> 参考来源: [Anthropic: Does Anthropic crawl data from the web, and how can site owners block the crawler?](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler)

## 4. 百度：反向 DNS 查询

> **官方文档已说明:**
> 百度建议对 IP 做反向 DNS 查询（`host`、`nslookup` 或 `dig -x`）。Baiduspider 的主机名是 `*.baidu.com` 或 `*.baidu.jp`。百度称其他主机名都是冒充的。
>
> 参考来源: [Baidu: FAQs of Baiduspider](https://help.baidu.com/question?prod_id=99&class=0&id=3001)

```sh
host 123.125.66.120   # → Baiduspider-123-125-66-120.crawl.baidu.com
```

百度的说明只做到反向查询这一步。再按 Google 的方法补一次正向查询，几乎没有成本，还能识破伪造的 PTR 记录。

## 5. 360 和头条：公布的 IP 段

> **官方文档已说明:**
> 360 搜索说明，它的爬虫暂时不支持 `nslookup` 查询。它建议对照公布的 IP 段确认。它的 User-Agent 末尾带有 `360Spider`。
>
> 参考来源: [360 Search: 360蜘蛛IP](https://www.so.com/help/spider_ip.html)

> **官方文档已说明:**
> 头条搜索的爬虫 UA 为 `Bytespider`，2019 年 11 月公布了 6 个 /24 IP 段。
>
> 参考来源: [Toutiao Search: 头条搜索spider介绍](https://www.toutiao.com/i6759451726496940557/)

这份列表是 2019 年的，也没有机器可读的版本。IP 对不上时，应记为「未验证」，不能直接当作冒充。

## 验证

- 抽查：为每个自称的爬虫挑一个请求，手动检查一遍。
- 在报表中区分*自称的*和*已验证的*爬虫流量。带有某爬虫 user-agent 但未通过验证的请求，是另一类流量，不应计入该爬虫。

## 回滚

验证本身是只读操作。如果你据此加了防火墙规则，就删除它们，改用 robots.txt 规则（[为 AI 爬虫配置 robots.txt](https://geo.casa/zh-cn/crawling-indexing/robots-txt-ai-crawlers/)）。

## 常见错误

- 只相信 user-agent 字符串。
- 永久缓存 IP 列表。这些文件带有 `creationTime` 并会更新，应定期刷新。
- 按 user-agent 字符串屏蔽未验证的「Googlebot」。冒充者换个字符串就绕过了。反过来，按 IP 屏蔽真实爬虫，又可能让它们读不到你的 robots.txt。

## 参考来源

- [Google: Verify requests from Google crawlers and fetchers](https://developers.google.com/crawling/docs/crawlers-fetchers/verify-google-requests)
- [OpenAI: Overview of OpenAI crawlers](https://developers.openai.com/api/docs/bots)
- [Perplexity: Perplexity crawlers](https://docs.perplexity.ai/docs/resources/perplexity-crawlers)
- [Anthropic: Does Anthropic crawl data from the web, and how can site owners block the crawler?](https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler)
- [Baidu: FAQs of Baiduspider](https://help.baidu.com/question?prod_id=99&class=0&id=3001)
- [360 Search: 360蜘蛛IP](https://www.so.com/help/spider_ip.html)
- [Toutiao Search: 头条搜索spider介绍](https://www.toutiao.com/i6759451726496940557/)
