脚本如下:
#!/bin/sh
# Copyright (C) 2015
OpenWrt.org
_input=/jffs/chnroute.txt
IPS=/usr/sbin/ipset
insmod ip_set
insmod ip_set_bitmap_ip
insmod ip_set_bitmap_ipmac
insmod ip_set_bitmap_port
insmod ip_set_hash_ip
insmod ip_set_hash_ipport
insmod ip_set_hash_ipportip
insmod ip_set_hash_ipportnet
insmod ip_set_hash_net
insmod ip_set_hash_netport
insmod ip_set_list_set
insmod xt_set
IPLIST=$(cat <<-EOF | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}"
0.0.0.0/8
10.0.0.0/8
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
EOF
$IPS -N ss_spec_lan_ac hash:ip
$IPS -! -R <<EOF
create ss_spec_wan_ac hash:net
$(egrep -v "^#|^$" $_input | sed -e "s/^/add ss_spec_wan_ac /")
EOF