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
/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.
-
-
1As 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. Commented Nov 30, 2023 at 15:28
-
@MichaelD The service you query should provide the subnet the requested IP address is part of.– Zac67 ♦Commented Nov 30, 2023 at 16:04