Coder Social home page Coder Social logo

nchnroutes's Introduction

nchnroutes

Similar to chnroutes, but instead generates routes that are not originating from Mainland China and generates result in BIRD static route format

Both IPv4 and IPv6 are supported.

As of Jul 2021, the size of generated table is roughly 11000-12000 entries for IPv4 (depends on the IP list used) and 14000 for IPv6. On a Raspberry Pi 4 with BIRD, full loading and convergence over OSPF with RouterOS running on Mikrotik hEX takes around 5 seconds.

For practical usage, check out my blog post (available in Chinese only): https://idndx.com/use-routeros-ospf-and-raspberry-pi-to-create-split-routing-for-different-ip-ranges/

Requires Python 3, no additional dependencies.

$ python3 produce.py -h

usage: produce.py [-h] [--exclude [CIDR [CIDR ...]]] [--next INTERFACE OR IP]
                  [--ipv4-list [{apnic,ipip} [{apnic,ipip} ...]]]

Generate non-China routes for BIRD.

optional arguments:
  -h, --help            show this help message and exit
  --exclude [CIDR [CIDR ...]]
                        IPv4 ranges to exclude in CIDR format
  --next INTERFACE OR IP
                        next hop for where non-China IP address, this is
                        usually the tunnel interface
  --ipv4-list [{apnic,ipip} [{apnic,ipip} ...]]
                        IPv4 lists to use when subtracting China based IP,
                        multiple lists can be used at the same time (default:
                        apnic ipip)

To specify China IPv4 list to use, use the --ipv4-list as the following:

  • python3 produce.py --ipv4-list ipip - only use list from ipip.net
  • python3 produce.py --ipv4-list apnic - only use list from APNIC
  • python3 produce.py --ipv4-list apnic ipip - use both lists (default)

If you want to run this automatically, you can first edit Makefile and uncomment the BIRD reload code at the end, then:

sudo crontab -e

and add 0 0 * * 0 make -C /path/to/nchnroutes to the file.

This will re generate the table every Sunday at midnight and reload BIRD afterwards.

nchnroutes's People

Contributors

dndx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nchnroutes's Issues

参数问题

屏幕截图 2021-12-18 091229
红线部分参数是否应该是bird4 -c configure

ipaddress.AddressValueError

When I use Python3 to run produce.py,the following:
Traceback (most recent call last):
File "/root/nchnroutes/produce.py", line 121, in
a = IPv4Network(line)
File "/usr/lib/python3.9/ipaddress.py", line 1502, in init
File "/usr/lib/python3.9/ipaddress.py", line 552, in _split_addr_prefix
File "/usr/lib/python3.9/ipaddress.py", line 162, in _split_optional_netmask
ipaddress.AddressValueError: Only one '/' permitted in '<h1>Not Found</h1>The requested URL /17mon/china_ip_list/master/china_ip_list.txt was not found on this server.'
make: *** [Makefile:4: produce] Error 1

Does anyone help me?

奈飞

大佬,我发现用了rbc不能访问奈飞,显示Not Available,应该是直连的没走clash.meta,是routes4.conf和routes6.conf里面没有奈飞的ip吗

执行make报个错

root@OpenWrt:/nchnroutes# nano produce.py
root@OpenWrt:
/nchnroutes# make
git pull
Already up to date.
curl -o delegated-apnic-latest https://ftp.apnic.net/stats/apnic/delegated-apnic-latest
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3400k 100 3400k 0 0 601k 0 0:00:05 0:00:05 --:--:-- 702k
curl -o china_ip_list.txt https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 95267 100 95267 0 0 285k 0 --:--:-- --:--:-- --:--:-- 288k
python3 produce.py
Traceback (most recent call last):
File "/root/nchnroutes/produce.py", line 3, in
import urllib.request
ModuleNotFoundError: No module named 'urllib'
make: *** [Makefile:5: produce] Error 1

缺失很多路由信息

生成的文件缺失很多路由信息,比如:172.217.0.0/16;2606:4700:20::/44 等等好多

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.