IP Geolocation Script

This repository contains a small script that you can use when you need to geolocate a bunch of IP addresses. It uses the IP2C API, which is free and doesn’t require any registration or API key.

It takes a file containing a list of IPs as an input, and outputs a CSV friendly format.

Input file format: a file containing one IPv4 address per line, in dotted notation (e.g.

Output file format: IP, ISO2 country code, Country name


python geolocate.py ip_file > geolocalized_ips

Sample result:,US,United States,CH,Switzerland,FR,France,US,United States

Script here: https://github.com/christophetd/geolocate-ips

Leave a Comment