1

Would a /24 public ip range typically be from the same country? This to reduce the amount of ipstack requests, checking from what country an IP is. (due to bot requests)

1 Answer 1

1

/24 is the longest prefix you can advertise over BGP, so it's generally atomic within an AS. However, there's nothing stopping the AS from routing each single address to different parts of the globe.

Accordingly, a /24 network within a single country is likely but there's no guarantee.

If you've got some kind of check-country-before-reply mechanism running, you should cache the results and base the cache on the queried subnet, not on each single address.

And of course, any geolocation query should always be taken with a grain of salt, as it's roughly 30% guesswork.

3
  • "the queried subnet" , being /24 ?
    – MichaelD
    Nov 30, 2023 at 11:40
  • 1
    As Zac67 said, /24 is the smallest network (longest prefix) you can advertise as a single network via BGP on the internet so it should be trusted to be a 'single network' but that does not mean all of the IP addresses in a /24 are used by devices in a single location or region. The network operator could proxy traffic via those IPs to other regions, could route over private links (or internet services) to other locations, or could use the IPs in many locations via solutions such as anycast. Basically they are 'probably' all in one region but you can't know for sure. Nov 30, 2023 at 15:28
  • @MichaelD The service you query should provide the subnet the requested IP address is part of.
    – Zac67
    Nov 30, 2023 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.