Created
July 20, 2015 08:37
-
-
Save jackyyf/0802ce18a9302861ccde to your computer and use it in GitHub Desktop.
Gist by paste.py @ 2015-07-20 16:37:49.741682
This file contains 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 | |
CHN_GW=192.168.1.1 | |
CHN_METRIC=5 | |
CHN_DEV=eth0 | |
for _route in `cat /usr/lib/routetable.txt | awk '{FS="|"}{if($2=="CN" && $3=="ipv4"){print $4 "/" (32-log($5)/log(2))}}'` | |
do | |
ip route add "$_route" metric "$CHN_METRIC" via "$CHN_GW" dev "$CHN_DEV" | |
done | |
This file contains 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 -4 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O /usr/lib/routetable.txt | |
if [[ $? -ne 0 ]]; | |
then | |
wget -6 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O /usr/lib/routetable.txt | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment