Skip to content

Instantly share code, notes, and snippets.

@zhihuiyuze
Last active June 26, 2021 16:47
Show Gist options
  • Save zhihuiyuze/d3bcfed6bac76166f2a5dbe958570728 to your computer and use it in GitHub Desktop.
Save zhihuiyuze/d3bcfed6bac76166f2a5dbe958570728 to your computer and use it in GitHub Desktop.
openwrt china ipset | openwrt mwan3分流 ipset
#!/bin/sh /etc/rc.common
# OpenWrt /etc/init.d/ script to automatically add ipsets across reboots
# For more info about how to write init scripts https://openwrt.org/docs/techref/initscripts
#
# howto:
# - #mkdir -p /etc/ipset/
# - upload this file as /etc/init.d/autoipset
# - # chmod 755 /etc/init.d/autoipset
# - # /etc/init.d/autoipset enable
# - # /etc/init.d/autoipset start
# queue this init script to start (i.e., create IPSet) right before dnsmasq starts (19)
START=18
update_cn_zone(){
rm /etc/ipset/cn.zone
/usr/bin/wget -P /etc/ipset http://www.ipdeny.com/ipblocks/data/countries/cn.zone
}
setipset() {
ipset -N direct hash:net
ipset -N china hash:net
for i in $(cat /etc/ipset/direct.zone ); do ipset -A direct $i; done
for i in $(cat /etc/ipset/cn.zone ); do ipset -A china $i; done
# ipset save
}
start() {
sleep 3s
update_cn_zone
setipset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment