Created
October 29, 2014 07:20
-
-
Save ice-age/34071178cbcb727e1de4 to your computer and use it in GitHub Desktop.
生成路由添加批处理文件。国内路由直接走本地,不走vpn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O apnic-ip | |
| echo "@echo off" >cn_route_via_local.bat | |
| cat apnic-ip |grep "^apnic"|grep ipv4|grep CN|awk -F'|' '{print $4,$5}'|while read ip count | |
| do | |
| echo $ip,$count | |
| count=`expr $count - 1` | |
| count=`echo "obase=2;$count"|bc|awk '{print length($0)}'` | |
| mask_count=`expr 32 - $count` | |
| echo "route add $ip/$mask_count 172.16.70.1" >>cn_route_via_local.bat | |
| done | |
| echo "pause" >>cn_route_via_local.bat | |
| unix2dos cn_route_via_local.bat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
根据 ip 个数求掩码可以用 log2(count) 函数