
使用 ss-redir 转发,端口 1080
ipset create chinaip hash:ip ipset add chinaip 0.0.0.0/8 ipset add chinaip 10.0.0.0/8 ipset add chinaip 127.0.0.0/8 ipset add chinaip 169.254.0.0/16 ipset add chinaip 172.16.0.0/12 ipset add chinaip 192.168.0.0/16 ipset add chinaip 224.0.0.0/4 ipset add chinaip 240.0.0.0/4 ipset add chinaip $SERVER_addr iptables -t nat -A PREROUTING -p tcp -m set ! --match-set chinaip dst -j REDIRECT --to-port 1080 iptables -t nat -A OUTPUT -p tcp -m set ! --match-set chinaip dst -j REDIRECT --to-port 1080 就是不知到在 dnsmasq 上怎么写,是这样吗?(应该不是吧)
ipset=/1.0.1.0/24/chinaip ipset=/1.0.2.0/23/chinaip ... 1 tony1016 2016-03-30 13:28:40 +08:00 为什么要在 dnsmasq 里面写,用 curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > chnroute.txt 生成后导入 |
2 MATTHEW728960 OP @tony1016 我已经有 chnroute.txt 这样的文件了,但还是要匹配的中国 ip 怎样使用的问题啊 ipset create chinaip hash:ip (好像应改为 hash:net ) iptables -t nat -A PREROUTING -p tcp -m set ! --match-set chinaip dst -j REDIRECT --to-port 1080 awk '!/^$/&&!/^#/{printf("ipset=/%s/'"chinaip"'\n",$0)}' \ chnroute.txt > /etc/dnsmasq.d/ipset.conf |