Skip to content

IP to country databases

Rob Janssen edited this page Oct 22, 2019 · 12 revisions

Data source: DbIpCSVFileSource

Example:

var resolver = new IP2CountryResolver(
    new DbIpCSVFileSource(@"D:\files\dbip-country-lite-2019-10.csv.gz")
);

Data source: IP2IQCSVFileSource

Example:

var resolver = new IP2CountryResolver(
    new IP2IQCSVFileSource(@"D:\files\ip2-cc.csv.gz")
);

Data source: IP2LocationFileSource

See IP2Location LITE Support for more information. You'll need an account to download these files.

Example:

var resolver = new IP2CountryResolver(
    new IP2LocationFileSource(@"D:\files\IP2LOCATION-LITE-DB11.CSV")
);

Data source: LudostCSVFileSource

Example:

var resolver = new IP2CountryResolver(
    new LudostCSVFileSource(@"D:\files\country.db.gz")
);

Data source: IpToAsnCSVFileSource

var resolver = new IP2CountryResolver(new IIP2CountryDataSource[] {
    new IpToAsnCSVFileSource(@"D:\files\ip2country-v4.tsv.gz"),
    new IpToAsnCSVFileSource(@"D:\files\ip2country-v6.tsv.gz")
});

Data source: MarkusGoCSVFileSource

Example:

var resolver = new IP2CountryResolver(
    new MarkusGoCSVFileSource(@"D:\files\ip2country.zip")
);

Data source: MaxMindGeoLiteIPFileSource

Example:

var resolver = new IP2CountryResolver(
    // City level file
    new MaxMindGeoLiteFileSource(@"D:\files\GeoLite2-City-CSV_20190305.zip")
);
// OR:
var resolver = new IP2CountryResolver(
    // Country level file
    new MaxMindGeoLiteFileSource(@"D:\files\GeoLite2-Country-CSV_20190305.zip")
);
// OR:
var resolver = new IP2CountryResolver(
    // ASN file (doesn't contain country info)
    new MaxMindGeoLiteFileSource(@"D:\files\GeoLite2-ASN-CSV_20190305.zip")
);

Note that the constructor allows you to specify your preferred language (as long as it's included in the files obviously) and wether you want to read only IPv4 or IPv6 data or both.

Registries (RIPE, APNIC, ARIN, LACNIC and AFRINIC)

Data source: RegistryCSVFileSource

Example:

var resolver = new IP2CountryResolver(new IIP2CountryDataSource[] {
    new RegistryCSVFileSource(@"D:\files\delegated-ripencc-extended-latest"),
    new RegistryCSVFileSource(@"D:\files\delegated-apnic-extended-latest"),
    new RegistryCSVFileSource(@"D:\files\delegated-arin-extended-latest"),
    new RegistryCSVFileSource(@"D:\files\delegated-lacnic-extended-latest"),
    new RegistryCSVFileSource(@"D:\files\delegated-afrinic-extended-latest")
});

Data source: WebNet77IPv4CSVFileSource

Data source: WebNet77IPv6CSVFileSource

Example:

var resolver = new IP2CountryResolver(new IIP2CountryDataSource[] {
    new WebNet77IPv4CSVFileSource(@"D:\files\IpToCountry.csv.gz"),
    new WebNet77IPv6CSVFileSource(@"D:\files\IpToCountry.6R.csv.gz")
});