Resolving an IP Address to Location Using Maxmind

If you buy an item online, but don’t include your address in the order, then your effort is wasted as the object of your desire cannot find its way to you.  So it is with Internet Protocol (IP).  When a person visits a website, his request to the server contains an IP address – the destination to which the server’s response must be sent.

The trick of matching up a visitor’s IP address to an actual physical location is achieved through a third-party service.  FreeGeoIP is a popular one.  It exposes a free API that will return the latitude, longitude, city, and country of a visitor based on his IP address.  There is no need to be paranoid though: this service can only identify a city or country.

The data that FreeGeoip uses is a freely downloadable location database, which can be obtained from Maxmind.

For a bit of fun, here’s the best guess for your location, using the freegeoip.net API.

[php snippet=1]

 

2 Comments

  1. milo kane says:

    Right city, anyhow. Only about 500,000 people live here

    • admin says:

      It gives me Dublin as well, even though I am in South Kilkenny!

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This