If you parse your Nginx, Caddy, or WordPress access logs for OAI-SearchBot, GPTBot, or PerplexityBot using only the User-Agent header, a large chunk of your "AI crawler traffic" is probably scrapers spoofing OpenAI's header.

Anyone can run curl -A "GPTBot/1.0" https://example.com. Counting raw User-Agent matches inflates AI crawl reports, pollutes GEO attribution, and makes it impossible to know whether ChatGPT Search or Perplexity is actually indexing your pages.

When we built verified AI crawler tracking for CitePulse, we needed a lightweight, zero-dependency way to verify official crawler IPs—both on the server and directly inside the browser (so agencies can upload server logs without raw visitor IPs ever leaving their device).

Here is the exact pattern.

1. The Official Machine-Readable Crawler IP Feeds

Only verify bots whose vendors publish official, machine-readable prefix lists; mark every other bot as unverifiable rather than guessing:

export const BOT_RANGE_SOURCES: Record<string, string> = { "OAI-SearchBot": "https://openai.com/searchbot.json", "GPTBot": "https://openai.com/gptbot.json", "ChatGPT-User": "https://openai.com/chatgpt-user.json", "PerplexityBot": "https://www.perplexity.com/perplexitybot.json", "Perplexity-User": "https://www.perplexity.com/perplexity-user.json", }; 

Each JSON file follows the same prefixes schema (ipv4Prefix and/or ipv6Prefix):

{ "creationTime": "2026-11-01T00:00:00Z", "prefixes": [ { "ipv4Prefix": "23.98.142.176/28" }, { "ipv6Prefix": "2603:1030:..." } ] } 

Caching rules that matter in production:

  • Cache fetched ranges for 24 hours (never fetch on every incoming request).
  • Never cache empty results if an upstream fetch times out—fall back to the last good snapshot or return unverifiable instead of falsely marking real bots as spoofed.

2. Never Trust X-Forwarded-For Directly

Before checking CIDR ranges, make sure you extract the real peer IP:

  • Behind Cloudflare: prefer CF-Connecting-IP only when the direct TCP connection comes from Cloudflare, otherwise fall back to REMOTE_ADDR.
  • Never trust a client-supplied X-Forwarded-For header blindly—an attacker spoofing User-Agent: OAI-SearchBot can spoof X-Forwarded-For: 23.98.142.177 in the exact same request.

3. Zero-Dependency IPv4, IPv6, and IPv4-Mapped CIDR Matching with BigInt

A surprisingly common edge case on dual-stack Linux servers (Node.js, Caddy, Nginx) is IPv4-mapped IPv6 addresses like ::ffff:23.98.142.177. If your matcher treats that string as IPv6 and compares it only against ipv6Prefix, legitimate OpenAI IPv4 crawlers fail verification.

Normalizing IPv4-mapped IPv6 back to IPv4 and doing bitwise prefix comparison with BigInt handles both protocols in ~70 lines with zero npm packages:

type ParsedIp = { version: 4 | 6; value: bigint }; type ParsedCidr = ParsedIp & { prefix: number }; function parseIpv4(text: string): bigint | null { const parts = text.split("."); if (parts.length !== 4) return null; let value = 0n; for (const part of parts) { if (!/^(0|[1-9]\d{0,2})$/.test(part)) return null; const n = Number(part); if (n > 255) return null; value = (value << 8n) | BigInt(n); } return value; } function parseIpv6(text: string): bigint | null { if (!/^[0-9a-fA-F:.]+$/.test(text)) return null; const halves = text.split("::"); if (halves.length > 2) return null; const toWords = (part: string, ends: boolean): number[] | null => { if (part === "") return []; const groups = part.split(":"); const out: number[] = []; for (let i = 0; i < groups.length; i++) { const g = groups[i]!; if (g.includes(".")) { if (!ends || i !== groups.length - 1) return null; const v4 = parseIpv4(g); if (v4 === null) return null; out.push(Number(v4 >> 16n), Number(v4 & 0xffffn)); } else { if (!/^[0-9a-fA-F]{1,4}$/.test(g)) return null; out.push(parseInt(g, 16)); } } return out; }; const head = toWords(halves[0]!, halves.length === 1); const tail = halves.length === 2 ? toWords(halves[1]!, true) : []; if (!head || !tail) return null; let words = head; if (halves.length === 2) { const missing = 8 - head.length - tail.length; if (missing < 1) return null; words = [...head, ...new Array<number>(missing).fill(0), ...tail]; } if (words.length !== 8) return null; return words.reduce((acc, w) => (acc << 16n) | BigInt(w), 0n); } export function parseIp(raw: string): ParsedIp | null { const text = raw.trim(); if (!text) return null; if (!text.includes(":")) { const v4 = parseIpv4(text); return v4 === null ? null : { version: 4, value: v4 }; } const v6 = parseIpv6(text); if (v6 === null) return null; // Normalize IPv4-mapped IPv6 (::ffff:a.b.c.d) back to IPv4 if (v6 >> 32n === 0xffffn) { return { version: 4, value: v6 & 0xffffffffn }; } return { version: 6, value: v6 }; } export function ipInCidr(ip: ParsedIp, cidr: ParsedCidr): boolean { if (ip.version !== cidr.version) return false; const bits = ip.version === 4 ? 32 : 128; if (cidr.prefix === 0) return true; const shift = BigInt(bits - cidr.prefix); return (ip.value >> shift) === (cidr.value >> shift); } 

4. Three-State Verdicts Beat Booleans

Always classify every claimed AI bot request into three states rather than true/false:

  1. verified: Bot has an official range feed AND the client IP matches one of its CIDRs.
  2. spoofed: Bot has an official range feed (e.g. OAI-SearchBot) AND the client IP does NOT match any published CIDR. Drop these from AI crawl KPIs.
  3. unverifiable: Bot vendor does not publish a machine-readable IP list yet (or ranges failed to load). Keep these labeled separately so you never silently miscount them.

Check Whether Your Site Blocks Real AI Crawlers

Validating incoming bots is half the story—the other half is verifying your WAF isn't silently returning HTTP 403 to OAI-SearchBot or PerplexityBot while robots.txt says Allow: / (in our December 2026 audit of 70 SEO agency websites, 27.1% showed WAF or live crawler probe friction).

You can test any public site in 30 seconds for free (no sign-up) with our Technical AI Readiness checker.