Commit 07ca1340 authored by nanahira's avatar nanahira

add chnroute reverse

parent 39945254
/data
/dnsmasq-china-list
/chnroutes2
create chnrouter hash:net family inet
{% for subnet in {{chnrouteReverseList.chnroute_reverse}} %}
add chnrouter {{subnet}}
{% endfor %}
......@@ -24,6 +24,7 @@ initialize_ipset() {
{% endfor %}
ip rule add pref 80 to 172.16.0.0/12 lookup main && \
iptables-restore --noflush {{ansible_user_dir}}/iptables-gateways && \
ipset restore -f {{ansible_user_dir}}/nextgen-router/chnrouter-ipset && \
arp -f
true
}
......
netaddr==0.7.19
pyyaml
#!/usr/bin/env python3
from netaddr import *
import yaml
def read_yaml_file(name):
file = open(name, 'r', encoding="utf-8")
data = yaml.load(file, Loader=yaml.SafeLoader)
file.close()
return data
def write_yaml_file(name, data):
file = open(name, 'w', encoding="utf-8")
yaml.dump(data, file)
file.close()
universe = IPSet(['0.0.0.0/0'])
special = IPSet([line.strip() for line in open('special.txt')])
chnroutes = IPSet([line.strip() for line in open('../chnroutes2/chnroutes.txt') if not line.startswith('#')])
result = { 'chnroute_reverse': [] }
chnroute_reverse = universe - special - chnroutes
for route in chnroute_reverse.iter_cidrs():
result['chnroute_reverse'].append(str(route))
write_yaml_file("../data/chnroute_reverse.yaml", result)
#!/usr/bin/env bash
if [ -d "chnroutes2" ]; then
(cd chnroutes2 && git pull)
else
git clone https://github.com/misakaio/chnroutes2.git
fi
ln -sf chnroutes2/chnroutes.txt chnroutes.txt
#pip3 install -r requirements.txt
python3 route_helper.py
0.0.0.0/8
1.1.1.0/24
1.0.0.0/24
8.8.8.0/24
8.8.4.0/24
10.0.0.0/7
100.64.0.0/10
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.0.0.0/24
192.0.2.0/24
192.88.99.0/24
192.168.0.0/16
198.18.0.0/15
198.51.100.0/24
203.0.113.0/24
224.0.0.0/4
240.0.0.0/4
255.255.255.255
......@@ -58,10 +58,18 @@
with_items:
- iptables-forward.sh
- iptables-gateways-interpreter.sh
- name: load chnroute reverse list
include_vars:
name: chnrouteReverseList
file: ./data/chnroute_reverse.yaml
- name: localnet ipset file
template:
src: ./files/localnet-ipset.j2
dest: '{{ansible_user_dir}}/nextgen-router/localnet-ipset'
- name: chnroute_reverse ipset file
template:
src: ./files/chnrouter-ipset.j2
dest: '{{ansible_user_dir}}/nextgen-router/chnrouter-ipset'
- name: interfaces
become: true
template:
......
#!/bin/bash
download_repo() {
REPO_DIR=$1
REPO_URL=$2
echo "Downloading $REPO_DIR"
if [ -d "$REPO_DIR" ]; then
(cd "$REPO_DIR" && git pull)
else
git clone "$REPO_URL" "$REPO_URL"
fi
}
download_repo chnroutes2 https://github.com/misakaio/chnroutes2.git
download_repo dnsmasq-china-list https://github.com/felixonmars/dnsmasq-china-list.git
cd dnsmasq-china-list
git fetch origin master
git reset --hard FETCH_HEAD
make smartdns
cd ..
rm -rf ./data/china-list.conf
sed 's/114.114.114.114/china/g' ./dnsmasq-china-list/*.smartdns.conf >> ./data/china-list.conf
grep -P '^bogus-nxdomain=.+$' dnsmasq-china-list/bogus-nxdomain.china.conf | sed 's/=/ /g' >> ./data/china-list.conf
cd lists
python3 route_helper.py
cd ..
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment