Last active
August 29, 2015 14:08
-
-
Save jackyyf/5942fcc526823b9bae55 to your computer and use it in GitHub Desktop.
Gist by paste.py @ 2014-11-02 17:20:28.748826
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 | |
FDU_GW=10.131.235.1 | |
FDU_METRIC=1 | |
FDU_ROUTE=" | |
10.0.0.0/8 | |
61.129.42.0/24 | |
61.152.128.0/22 | |
175.186.0.0/16 | |
192.168.0.0/16 | |
202.120.64.0/20 | |
202.120.224.0/19 | |
140.207.196.0/24 | |
218.193.128.0/20 | |
" | |
CHN_GW=10.131.235.1 | |
CHN_METRIC=5 | |
ORZ_GW=10.131.235.9 | |
ORZ_METRIC=100 | |
# Default to OrzNet | |
echo "Flush routes..." | |
ip route flush default | |
service networking stop | |
service networking start | |
echo "Add OrzNet route..." | |
ip route change default via "$ORZ_GW" metric "$ORZ_METRIC" | |
# Fudan Routes | |
echo "Add Fudan route..." | |
for _route in $FDU_ROUTE | |
do | |
ip route add "$_route" metric "$FDU_METRIC" via "$FDU_GW" | |
done | |
# China Routes | |
echo "Add China route..." | |
for _route in `curl -6 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest | 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" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment