IP geographic location

22 11 2007

GeoIP is a nice service that provides free databases with IP to country/city relations. They have very nice APIs which might eventually come in handy when doing your every-day log analysis.

Given that I needed to find the assigned IPs to a certain country, and that the C API I saw provided no means of doing it, I created a small script that will drop all the IP addresses in a plaintext file. The information is taken from the CSV database.


./country2ip.sh database.csv Country_Name output_file

It is not intended to be efficient and it certainly is not. It is intended to be effective and it serves its purpose. Be aware of the extremely large files that it may generate.

Download here.

Some interesting info:

Brasil: 25,583,219 unique IP addresses
Uruguay: 17,174,982 unique IP addresses
Argentina: 4,996,274 unique IP addresses
Chile: 4,295,697 unique IP addresses
Venezuela: 3,186,405 unique IP addresses
Colombia: 3,120,548 unique IP addresses
Peru: 1,077,608 unique IP addresses
Ecuador: 767,728 unique IP addresses
Bolivia: 354,207 unique IP addresses
Paraguay: 83,328 unique IP addresses