简体   繁体   中英

Does the maxmind GeoIP API in PHP require all 4 segments of the IP address to be accurate?

I'm using geoip_record_by_addr from this package https://github.com/maxromanovsky/php-maxmind-geoip .

My question is can I safety 'zero' the last segment of IP addresses and get the same country and region?

Eg

geoip_record_by_addr($gi, '123.145.167.0')

instead of

geoip_record_by_addr($gi, '123.145.167.189')

I think, this question is related not to maxmind's logic, but to networks organization. maxmind - is simply database of networks ips of providers and well known registered addresses. In theory, if you use 123.123.123.1 you can find something, but I'm not sure that all IP from network 123.123.123.1/24 (123.123.123. ) are from same region.
Its better to make some research. write a script to select 50-100 networks..
for example IP 86.85.65. and check from where all these IPS (from 1 to 255). must be from Netherlands. then select another and check again.
then check dispersion of results =))) I think it will be the best solution (and the most correct) for you.

Btw, your example IP is not valid ('123.456.789.0'). max values for ipv4 addresses is 255.255.255.255 (this is broadcast IP as well as all last IP from subnets)

The short answer is yes. There is no reason to think that all the address in a /24 network will provide the same result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM