This question already has an answer here:

I was wondering about how some websites know the location of IP addresses we query them to resolve for it's location.

Then I remembered the IANA assigns IP addresses to different Regional Internet Registrars (RIR) like AFRINIC, APNIC, ARIN, LACNIC, RIPE NCC (as mentioned here https://www.iana.org/numbers) which are further subdivided to different National Internet Registries (NIR) like CNNIC, APJII, JPNIC, KRNIC, etc. for every region under RIR

I looked up to understand which IP ranges are provided to which RIR and further down the tree but didn't quite understand what they've written here in this link originated from the same page mentioned above.

Maybe I'm wrong but I think there is a hierarchy of IP range allocation with regards to their location otherwise how'd these online services know the location of that IP address. (Also not to forget, collaboration of multiple databases helps obviously)

I want to basically guess the location of an IP address based on some pattern associated with the way the IANA has done IP allocation to different RIR.

Can I guess the Geolocation of an IP simply based on it's pattern for both IPv4 and IPv6?

Please correct me if I am missing anything or am wrong in any concept.

EDIT: The answer posted by Steffen Ullrich does not touch on the concept of links between IP range allocation with regards to their location as is asked in this question but the link provided is also helpful to understand other things

marked as duplicate by Steffen Ullrich, Bacon Brad, Xiong Chiamiov, crovers, TheJulyPlot Jul 10 '17 at 6:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You can simply get it (with great accuracy) from databases, such as in Steffen's answer: It may also be helpful to read some of the FAQ's at commercial providers of GeoIP data such as Maxmind to give you an idea of how accurate the data may be. support.maxmind.com – ndrix Jul 8 '17 at 0:59
  • It does not help because there is not a single mention of how they do Geolocation reporting to users with regards to IP resolution queries. Other than in one instance where they have said that they update their database often. Where does this database come from? What is the source? – GypsyCosmonaut Jul 8 '17 at 1:18
  • 2
    @GypsyCosmonaut: the answers I have linked to do not touch the concept between allocation of IP range regarding geographic location simply because it does not work this way. – Steffen Ullrich Jul 8 '17 at 4:26

No, there is not. Blocks are moved, sold and sometimes mobile. Most base data comes from WHOIS databases and RIR databases, which are public. Refined data based on user data is added by some parties to make it more accurate, for example, gps, cell and wifi networks often are fixed locations and are sometimes submitted to profiling and advertising services when you use apps on mobile devices or shop online. This is also why the data can sometimes be very inaccurate; a fixed internet connection might have an IP from a block that is listed with the address of a regional ISP office instead of the service area where that block is used. This data usually gets updated when an ISP sells or moves or devides a block and updates the WHOIS data.

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