Anyone can send a request that calls itself GPTBot. The IP address is much harder to fake. Here is how to check a request against the IP ranges the AI companies publish themselves, by hand, in code, or with one API call.
Fake Googlebots are one of the oldest tricks on the web. Google and Bing both document how to catch them, but many guides still point at old URLs. Here are both methods, the current files, and code you can run.
The usual Nginx recipe for AI crawlers is a regex on the user agent. It blocks the honest bots and lets every impostor through. Here is a setup that checks the IP against the operators' own lists, generated automatically.
Looking up a country from an IP takes one HTTP request. Getting the right IP, handling IPv6 and private addresses, caching results and failing gracefully takes a little more. Working examples in four languages.
Automatically redirecting by IP looks simple, and it is one of the easiest ways to make your other country sites invisible in search. Here is what Google recommends, a pattern that works for people and crawlers, and code for it.
IP geolocation is an estimate built from registry records, operator feeds and network measurements. It is usually right about the country and only approximate about the city. Knowing why helps you use it where it works and avoid it where it doesn't.
IP geolocation
Guides
Try it
One GET request: location, network and bot signals
Free keys include 1,000 lookups a day. No card needed.