Skip to content

Latest commit

 

History

History
213 lines (165 loc) · 7.05 KB

README_en.md

File metadata and controls

213 lines (165 loc) · 7.05 KB

mmdb_china_ip_list

README | 中文说明

Daily Build Release Build

Overlap the Chinese IP list published by china_ip_list, chunzhen CN, Clang.CN and ali AS37963 into the official community edition database of MaxMind.

This is also an example of generating MaxMind Database!

It's suitable for using in network offloading tools and compatible with MaxMind DB client! It is more friendly to Chinese IP matching and distribution.

Automatically pull new MaxMind, china_ip_list, Chunzhen CN and Clang.cn database every week, and release a new Release version.

Fixed download connection

  • Both Release and Daily switch to build with the golang version of the mmdb writer
  • The full version is based on loading the official GeoLite2-Country.mmdb, overwriting china_ip_list, chunzhen CN and Clang.CN, not built from scratch
  • The Lite version is built from zero contains IPv4 Data & CN's IPv6 Data, written directly to china_ip_list, chunzhen CN and Clang.CN, and only iso_code and geoname_id are written to reduce the size.
File release (Daily) CDN (Daily)
Country.mmdb link link
Country.mmdb lite link link
version link link

Introduction

Is not very friendly to Chinese IP matching. So, there are many problems in actual using the GeoLite2-Country of MaxMind in network tapping tools (such as Clash).

This project, on the basis of the MaxMind database, added china_ip_list, chunzhen CN and Clang.CN, making it more friendly to Chinese IP matching.

Because the mmdb is built, the latter overrides the former, and the order of inserting the ip list is as follows:

  1. Clang.CN
  2. chunzhen CN
  3. china_ip_list

How to use

Download the generated china_ip_list.mmdb from Release.

The usage is the same as the official API of MaxMind, please refer to Guide Document.

Using in OpenClash

Rename china_ip_list.mmdb to Country.mmdb, then replace /etc/openclash/Country.mmdb, and finally restart clash.

You can edit the update url in update script and enable auto update.

Build mmdb by perl

The perl environment is required. For the dependency and use of MaxMind-DB-Writer-perl, please refer to Official Document.

# Download mmdb writer
git clone https://github.com/maxmind/MaxMind-DB-Writer-perl.git writer
cd writer

# Install dependencies
curl -LO http://xrl.us/cpanm
perl cpanm –installdeps .

# Build
./Build manifest
perl Build.PL
./Build install

# Return to parent directory
cd ..

# Clone this project
git clone https://github.com/alecthw/mmdb_china_ip_list.git
cd mmdb_china_ip_list

# Download GeoLite2-Country-CSV
curl -LR -o GeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=JvbzLLx7qBZT&suffix=zip"
unzip GeoLite2-Country-CSV.zip
rm -f GeoLite2-Country-CSV.zip
mv GeoLite2* mindmax

# Download china_ip_list
curl -LR -o china_ip_list.txt "https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt"

# Download Chunzhen CN
curl -LR -o chunzhen_cn.txt "https://raw.githubusercontent.com/metowolf/iplist/master/data/special/china.txt"

# Generate mmdb
perl china_ip_list.pl

The generated file ischina_ip_list.mmdb

MaxMind GeoIP Format

The official said little about the content of their own database. It's the format that I found out with debugging the source code. And then generated the database.

Examples of all fields are listed below for reference.

header

{
    "database_type": "GeoLite2-Country",
    "binary_format_major_version": 2,
    "build_epoch": 1589304057,
    "ip_version": 6,
    "languages": [
        "de",
        "en",
        "es",
        "fr",
        "ja",
        "pt-BR",
        "ru",
        "zh-CN"
    ],
    "description": {
        "en": "GeoLite2 Country database"
    },
    "record_size": 24,
    "node_count": 616946,
    "binary_format_minor_version": 0
}

network-field

{
    "continent": {
        "code": "AS",
        "names": {
            "de": "Asien",
            "ru": "Азия",
            "pt-BR": "Ásia",
            "ja": "アジア",
            "en": "Asia",
            "fr": "Asie",
            "zh-CN": "亚洲",
            "es": "Asia"
        },
        "geoname_id": 6255147
    },
    "country": {
        "names": {
            "de": "China",
            "ru": "Китай",
            "pt-BR": "China",
            "ja": "中国",
            "en": "China",
            "fr": "Chine",
            "zh-CN": "中国",
            "es": "China"
        },
        "iso_code": "CN",
        "geoname_id": 1814991,
        "is_in_european_union": false,
    },
    "registered_country": {
        "names": {
            "de": "China",
            "ru": "Китай",
            "pt-BR": "China",
            "ja": "中国",
            "en": "China",
            "fr": "Chine",
            "zh-CN": "中国",
            "es": "China"
        },
        "iso_code": "CN",
        "geoname_id": 1814991
    },
    "represented_country": {
        "names": {
            "de": "China",
            "ru": "Китай",
            "pt-BR": "China",
            "ja": "中国",
            "en": "China",
            "fr": "Chine",
            "zh-CN": "中国",
            "es": "China"
        },
        "iso_code": "CN",
        "geoname_id": 1814991
    },
    "traits": {
        "is_anonymous_proxy": true,
        "is_satellite_provider": true
    }
}

Thanks

Last

It's not easy to find out. I hope to leave a name for citation integration or secondary release...