#!/bin/bash
CN_IP_LIST=$(curl -k https://gaoyifan.github.io/china-operator-ip/china.txt)
echo -e "create chnip hash:net family inet hashsize 1024 maxelem 65536" > /tmp/ipset.conf
for IP_CIDR in ${CN_IP_LIST};do
    echo -e "add chnip ${IP_CIDR}" >> /tmp/ipset.conf
done
cat >> /tmp/ipset.conf <<EOF
create ahct hash:net family inet hashsize 1024 maxelem 65536
add ahct 61.133.128.0/18
add ahct 61.190.0.0/16
add ahct 60.168.0.0/13
add ahct 36.4.0.0/14
add ahct 223.240.0.0/13
add ahct 103.22.16.0/22
add ahct 117.57.0.0/16
add ahct 124.73.0.0/16
add ahct 117.64.0.0/13
add ahct 183.160.0.0/13
add ahct 114.104.0.0/14
add ahct 124.112.0.0/15
add ahct 60.166.0.0/15
add ahct 114.96.0.0/13
add ahct 218.22.0.0/15
add ahct 36.56.0.0/13
add ahct 223.214.0.0/15
create do hash:net family inet hashsize 1024 maxelem 65536
add do 134.209.192.0/20
add do 104.248.176.0/20
add do 104.131.128.0/20
add do 134.209.136.0/22
add do 104.131.0.0/18
add do 137.184.32.0/20
add do 104.248.96.0/22
add do 104.248.160.0/20
add do 134.209.0.0/20
add do 138.197.176.0/20
add do 104.131.192.0/19
add do 137.184.16.0/20
add do 138.197.112.0/20
add do 134.209.112.0/20
add do 104.248.32.0/20
add do 134.209.176.0/20
add do 134.122.64.0/20
add do 104.248.192.0/20
add do 137.184.248.0/22
add do 104.248.64.0/20
add do 134.122.48.0/20
add do 104.248.224.0/20
add do 104.236.64.0/18
add do 107.170.128.0/19
add do 107.170.0.0/17
add do 104.248.48.0/20
add do 137.184.192.0/20
add do 137.184.0.0/20
add do 137.184.96.0/20
add do 138.197.144.0/20
add do 104.131.144.0/20
add do 138.197.16.0/20
add do 134.209.32.0/20
add do 134.209.96.0/20
add do 104.248.0.0/20
add do 134.122.96.0/20
add do 134.209.80.0/20
add do 128.199.16.0/20
add do 138.197.208.0/20
add do 138.197.160.0/20
add do 134.209.128.0/22
add do 104.248.104.0/22
add do 137.184.224.0/20
add do 128.199.32.0/19
add do 137.184.48.0/20
add do 134.209.132.0/22
add do 134.122.80.0/20
add do 104.248.208.0/20
add do 104.248.112.0/20
add do 134.209.48.0/20
add do 134.209.224.0/20
add do 107.170.192.0/18
add do 137.184.80.0/20
add do 134.122.112.0/20
add do 104.248.80.0/20
add do 104.131.176.0/20
add do 137.184.144.0/20
add do 137.184.128.0/20
add do 104.236.192.0/18
add do 134.209.16.0/20
add do 137.184.176.0/20
add do 104.248.100.0/22
add do 134.209.160.0/20
add do 134.122.16.0/20
add do 107.170.160.0/19
add do 128.199.192.0/18
add do 138.197.128.0/20
add do 134.122.0.0/20
add do 104.248.240.0/20
add do 134.209.140.0/22
add do 137.184.254.0/24
add do 138.197.224.0/22
add do 137.184.244.0/22
add do 104.248.16.0/20
add do 104.131.224.0/19
add do 137.184.160.0/20
add do 137.184.64.0/20
add do 138.197.0.0/20
add do 138.197.192.0/20
add do 137.184.240.0/22
add do 103.253.144.0/22
add do 134.209.208.0/20
add do 128.199.128.0/18
add do 137.184.252.0/24
add do 104.248.144.0/20
add do 138.197.228.0/22
add do 104.131.64.0/18
add do 128.199.0.0/20
add do 128.199.64.0/18
add do 104.236.128.0/18
add do 104.236.0.0/18
add do 104.131.160.0/20
add do 104.248.108.0/22
add do 104.248.128.0/20
add do 134.122.32.0/20
add do 134.209.144.0/20
add do 134.209.64.0/20
add do 137.184.208.0/20
add do 134.209.240.0/20
add do 137.184.112.0/20
EOF
sudo ipset restore < /tmp/ipset.conf
