#!/bin/sh
# create static_router.rsc and firewall address list
# CN IP Address
wget --no-check-certificate -c -O /data/repo/software/ispip/all_cn.txt https://ispip.clang.cn/all_cn.txt
# wget --no-check-certificate -c -O all_cn.txt http://www.iwik.org/ipcountry/CN.cidr

# /ip route add dst-address=223.29.252.0/22 gateway=121.14.41.209 comment=CN
# /ip route remove  [/ip route find comment=CN]

net_name="l2tp-cn"
# static_router (default in chn)
{
echo "/ip route"
for cidr in $(cat all_cn.txt) ; do
  echo "add dst-address=$cidr gateway=$net_name comment=CN"
done
} |tee /data/repo/software/ispip/static_router.rsc xxx1.rsc

# static_address_list (default in chn)
{
echo "/ip firewall address-list"
for address in $(cat all_cn.txt) ; do
  echo "add list=CN address=$address comment=chn_cidr"
done
} |tee /data/repo/software/ispip/static_address_list.rsc xxx2.rsc

rm -rf /data/repo/software/ispip/all_cn.txt
