https://github.com/lionsoul2014/ip2region

1 下载 xdb 数据库

https://github.com/lionsoul2014/ip2region/tree/master/data

2 安装.Net 软件包

Install-Package IP2Region.Net

3 代码

using IP2Region.Net.Abstractions;
using IP2Region.Net.XDB;

ISearcher searcher = new Searcher(CachePolicy , "your xdb file path");

//国家|区域|省份|城市|ISP
var result = searcher.Search(ip);

//如果解析不了,默认值为0

标签: ip, Ip2region