GeoIP2-CN
小巧精悍、准确、实用 GeoIP2 数据库
A compact, auto-updated database of mainland Chinese IP addresses that is 40x smaller and more accurate than MaxMind's free alternative, used by Surge, Clash, and Shadowrocket to decide when to use a proxy.
GeoIP2-CN is a compact database that records which IP addresses belong to mainland China. Tools like Surge, Clash, Shadowrocket, and QuantumultX use databases like this to decide whether a given internet connection should be routed directly or through a proxy. By knowing an IP belongs to China, those tools can send traffic there without a detour.
The common alternative for this task is MaxMind's free GeoLite2 database, but the README explains several problems with that option: it requires registration to download, it is roughly 4 megabytes in size, and its accuracy for mainland China addresses is poor, sometimes misclassifying cloud provider IPs as belonging to Hong Kong or Singapore. Wrong classifications cause proxy tools to make bad routing decisions, resulting in slow or broken connections to certain sites.
This project addresses those problems by combining two sources known for better China coverage, ipip.net and the Chunjun IP database, then merging and deduplicating the results into a file that contains only mainland Chinese address records. The result is roughly 100 kilobytes, a fraction of the MaxMind alternative, which means it loads faster and queries run more quickly.
The database updates automatically every three days with no manual intervention and is hosted on GitHub with CDN distribution for fast downloads. Two formats are available: a plain IP-CIDR list for firewalls and older tools, and a GeoIP2 .mmdb file for newer proxy applications. Configuration guides for Surge, QuantumultX, Shadowrocket, and Clash are linked from the project wiki.
One important limitation noted in the README is that this database contains only mainland China records. Rules that attempt to query for other countries such as the US, Australia, or Hong Kong will not work with it, since those entries are not present.
Where it fits
- Configure Clash or Surge to route mainland China traffic directly without a proxy using this more accurate database
- Replace MaxMind's GeoLite2 in your proxy tool with a smaller China-only file that requires no registration to download
- Set up firewall rules using the plain IP-CIDR list format to allow or block mainland Chinese IP ranges