An IP (short for “Internet Protocol”) address is a unique number assigned to every machine that connects to the internet. Nowadays, you can have multiple computers behind a router that share a single IP using Network Address Transformation (NAT). If you have ever used a wifi hotspot to access the internet, you’ve shared an IP address with someone.

It’s complex, but it boils down to it’s a numbers thing. IP4 was created when the internet was young, and they started running out of numbers. Think of IP6 as adding more numbers to a telephone number or a zip code, or a new area code.

There’s a giant database out there that contains all of the IP address ranges and their approximate locations. (Ours uses GeoLite2 City database (updated weekly), for example). They in turn get their information from the main repositories of IP Addresses (ARIN/APNIC/AFRINIC/LACNIC/RIPE, depending on where you are in the world). When you request IP Addresses from the repositories, you need to let them know approximately where those addresses will be. Additionally, many internet providers (for example, Comcast) will provide additional information on specific IP Addresses if you query their whois service. So, in a nutshell, all this information is public, and someone just goes and sucks it up into a database.  Think of it like a reverse phone book or something.

Also – we have a great little demo of how in-browser geolocation works in HTML.