{% extends "_layout.html" %} {% block title %}GeoIP File Specification{% endblock %} {% block content %} Updated May 2013, current as of router version 0.9.6

Overview

This page specifies the format of the various GeoIP files, used by the router to look up a country for an IP.

Country Name (countries.txt) Format

This format is easily generated from data files available from many public sources. For example:

# wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
# unzip GeoIPCountryCSV.zip
# cut -d, -f5,6 < GeoIPCountryWhois.csv |sed 's/"//g' | sort | uniq > countries.txt

IPv4 (geoip.txt) Format

This format is borrowed from Tor and is easily generated from data files available from many public sources. For example:

# wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
# unzip GeoIPCountryCSV.zip
# cut -d, -f3-5 < GeoIPCountryWhois.csv|sed 's/"//g' > geoip.txt
# cut -d, -f5,6 < GeoIPCountryWhois.csv |sed 's/"//g' | sort | uniq > countries.txt

IPv6 (geoipv6.dat.gz) Format

This is a compressed binary format designed for I2P. The file is gzipped. Ungzipped format:

   Bytes 0-9: Magic number "I2PGeoIPv6"
   Bytes 10-11: Version (0x0001)
   Bytes 12-15 Options (0x00000000) (future use)
   Bytes 16-23: Creation date (Java long)
   Bytes 24-xx: Optional comment (UTF-8)
   Bytes xx-255: null padding
   Bytes 256-: 18 byte records:
       8 byte from (/64)
       8 byte to (/64)
       2 byte ISO country code LOWER case (ASCII)

NOTES:

{% endblock %}