Generate optimized China mainland IP route tables from authoritative sources (APNIC, GitHub).
Dobby is free!
git clone https://github.com/helixzz/dobby-routes.git
cd dobby-routes
pip install -e .Or install dependencies directly:
pip install -r requirements.txt# Generate all route tables (default output to ./output/)
dobby-routes
# Specify output directory
dobby-routes --output-dir /path/to/output
# Override repository-local route list directories
dobby-routes --allowlist-dir /path/to/allowlists --denylist-dir /path/to/denylists
# Skip GitHub sources (APNIC only)
dobby-routes --skip-github
# Skip APNIC source (GitHub only)
dobby-routes --skip-apnic
# Generate from local allowlists only
dobby-routes --skip-apnic --skip-github
# Verbose logging
dobby-routes -vBy default, Dobby Routes reads direct regular files from ./allowlists and ./denylists.
Use --allowlist-dir and --denylist-dir to override those directories. Missing directories are
ignored; a path that exists but is not a directory is an error.
Each file is UTF-8 text with one IPv4 address or CIDR per line. Blank lines and full-line #
comments are ignored. Invalid entries are skipped with a warning. IPv6 CIDRs are explicitly warned
and skipped because current route tables are IPv4-only. Files are read by filename in deterministic
order, without recursively traversing subdirectories.
Local files can include a remote CIDR source with an exact directive on its own line:
@include https://example.com/routes.txt
Only @include <URL> is accepted: inline comments, extra tokens, and other @ directives are
errors. Includes require HTTPS with a hostname, no userinfo, fragments, whitespace, or non-default
ports. localhost, .localhost, and non-global literal IP hosts are rejected. Redirects are not
followed, downloaded bodies are limited to 5 MiB, and any include failure stops generation. Included
content is parsed as IPv4 CIDRs only; @include lines inside remote content are invalid rather than
recursive includes.
Allowlist routes are added to the remote APNIC and GitHub routes. Denylist routes are then removed from that union, so the denylist always takes precedence. All resulting forward routes are filtered to exclude private, reserved, multicast, documentation, and other non-routable IPv4 ranges.
Local-only generation is supported with --skip-apnic --skip-github when an allowlist contains at
least one route. A denylist by itself is not a source of forward routes. Local-only routes receive
the CN annotation unless they also match a fetched operator route.
The checked-in denylists/telegram.txt includes Telegram's official CIDR source. Its IPv4 ranges
are removed from forward routes and therefore covered by the inverse route table; its IPv6 entries
are skipped. This built-in URL is pinned to reviewed IPv4 ranges: an upstream addition outside that
scope fails generation until maintainers review and update the approved scope. Other custom URL
files are trusted local configuration and are not constrained to Telegram's reviewed scope. Local
includes are loaded regardless of the remote-source skip flags.
The tool generates three files:
Forward route table with operator annotations (ASN and name).
# China mainland IP route table (annotated)
# Generated by dobby-routes on 2025-04-13 12:00:00 UTC
# Total routes: 8432
#
1.0.1.0/24 # AS4134/AS4812 China Telecom
1.0.2.0/23 # AS4134/AS4812 China Telecom
1.1.0.0/24 # CN
1.1.4.0/22 # AS4837/AS9929 China Unicom
Forward route table, fully optimized (merged and deduplicated). No comments.
# China mainland IP route table (optimized)
# Generated by dobby-routes on 2025-04-13 12:00:00 UTC
# Total routes: 6120
#
1.0.1.0/24
1.0.2.0/23
1.0.8.0/21
Inverse route table — the complement of the final forward routes within the routable IPv4 universe. Private, reserved, multicast, documentation, and other non-routable IPv4 ranges are excluded. Fully optimized.
# Inverse route table (complement of China mainland routes)
# Generated by dobby-routes on 2025-04-13 12:00:00 UTC
# Total routes: 5890
#
1.0.0.0/24
8.0.0.0/7
| Source | URL | Update Frequency |
|---|---|---|
| APNIC Delegated | ftp.apnic.net/stats/apnic/delegated-apnic-latest |
Daily |
| China Telecom | gaoyifan/china-operator-ip (chinanet.txt) |
Daily |
| China Unicom | gaoyifan/china-operator-ip (unicom.txt) |
Daily |
| China Mobile | gaoyifan/china-operator-ip (cmcc.txt) |
Daily |
| CERNET | gaoyifan/china-operator-ip (cernet.txt) |
Daily |
| chnroutes2 | chnroutes2.cdn.skk.moe optimized list; fallback to misakaio/chnroutes2 |
2 hours / hourly fallback |
Route tables are updated daily via GitHub Actions and published to the data branch. The scheduled workflow automatically uses the repository's allowlists/ and denylists/ directories with explicit workspace paths, so committed local route rules are included in every update.
Direct download links:
https://raw.githubusercontent.com/helixzz/dobby-routes/data/cn_routes.txt
https://raw.githubusercontent.com/helixzz/dobby-routes/data/cn_routes_annotated.txt
https://raw.githubusercontent.com/helixzz/dobby-routes/data/cn_routes_inverse.txt
pip install -e ".[dev]"
pytest