In order to map the IP address to a geographical representation, the system needs the geographical data mapping. This data is provided by several companies. One can use the GEOLiteCity data, which is free. To obtain this data, visit
http://www.maxmind.com/app/geolitecity and download the ZIP file which contains two files, Blocks and Location CSV. The block file maps an IP number range to a location. The location file has the geographical information. Please note that there are frequent updates to these files, so make sure you read the description of their services.