Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind 3.1.0

Prefix Reserved
dotnet add package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind --version 3.1.0
                    
NuGet\Install-Package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind -Version 3.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" Version="3.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" Version="3.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind --version 3.1.0
                    
#r "nuget: Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind, 3.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind@3.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind&version=3.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind&version=3.1.0
                    
Install as a Cake Tool

Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind

Loads a whole MaxMind DB file, such as a GeoIP2, GeoLite2 or ASN database, into a lookup table. MaxMind's Reader walks the file's search tree one bit at a time and decodes a record on every lookup. MaxMindDatabase.Load decodes every record once and builds a longest-prefix-match lookup from the networks.

dotnet add package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind

Or from the NuGet Package Manager console:

PM> NuGet\Install-Package Bitvantage.InternetProtocol.NetworkPrefixLookup.MaxMind
using System.Net;
using Bitvantage.InternetProtocol.NetworkPrefixLookup;

var countries = MaxMindDatabase.Load<Dictionary<string, object>>("GeoLite2-Country.mmdb").Freeze();
if (countries.TryGetMatchValue(IPAddress.Parse("81.2.69.160"), out var record))
    Console.WriteLine(((Dictionary<string, object>)record["country"])["iso_code"]); // GB

On an AMD Ryzen 7 7800X3D, with a database the size of a full routing table, 1,240,422 IPv4 and 413,309 IPv6 networks:

MaxMind Reader.Find Read-write lookup Frozen lookup
Time per lookup 254 ns 38 ns 27 ns
Allocated per lookup 344 bytes Nothing Nothing

The lookup costs time to load and memory to hold. That database took 0.9 seconds to load and the read-write lookup held 225 MB, where the reader opens at once and maps the 19 MB file. The lookup pays off when an application looks up many addresses, such as a server that checks every request or a job that processes logs. For a few lookups, or where memory is tight, MaxMind's reader is the better choice.

MaxMind lookups map IPv4-mapped addresses such as ::ffff:81.2.69.160 to IPv4 by default, as MaxMind's reader does. Set MaxMindLoadOptions.IncludeAliasedNetworks to also load the IPv4-compatible, 6to4 and Teredo aliases of MaxMind's IPv6 databases, so that every address gets the answer that Reader.Find gives.

Load only databases you trust. A database's search tree can point many branches at one subtree, so a hostile file of a few hundred bytes can expand into millions of networks.

The lookups have the same members as the core package's lookups for System.Net.IPNetwork, including queries about networks and frozen tables. The main README describes them.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 36 11/12/2026
3.0.0 57 11/11/2026