Create an IP to location web service
In this tutorial, we demonstrate how to create an IP to location index and then serve it in a simple web application.
The data used to create an IP to location index is publicly available from the Internet routing registries (IRRs) (opens in a new tab) which includes the Regional Internet Registries (RIRs) (opens in a new tab)
The data are formatted following RPSL (opens in a new tab) specifications and contain records that link IP address ranges to organisations along with some metadata.
baremaps workflow execute --file workflow.js
The workflow executed in the above command does the following:
- Download and decompress the data from the IRRs
- Download and create a Geocoding index (see the Geocoding example)
- Iterate over every entry in the registries to extract the IP address ranges and the associated metadata to query the Geocoding index and extract a latitude and a longitude.
baremaps iploc serve --database iploc.db --port 9000
A simple web application serves the Geonames index. Go to http://localhost:9000/ (opens in a new tab) to see it in action.
In this tutorial, we learnt how to create an IP to location index and serve it in a simple web application. IP to location has many uses, one of which is to locate users that connect to a website to generate statistics.