首先感谢github 上的https://github.com/jimmyxu/chnroutes 下面的脚本只是为了我这类懒人而写的纯傻瓜操作且仅限Mac用户。其他平台请自行参照项目地址中的说明文件. 备注, 此bash会在你的/etc/ppp下面生成两个文件. 也就是这两个文件会使你的访问分流. 并且最好定期更新这两个文件. 保存并执行下面的bash即可.

#!/bin/bash
#auth:Simon #mail:simon.xie@codewalker.me

export tmpDirForVpnController=/tmp/tmp.route.vpn.dir
export downloadFileAddress=’https://github.com/ranmocy/chnroutes/archive/master.zip

function checkFiles {
echo ‘checkFiles…’
if [ ! -d $tmpDirForVpnController ];then
echo ‘folder no found, create it’ $tmpDirForVpnController
mkdir -p $tmpDirForVpnController;
fi
cd $tmpDirForVpnController
if [ ! -d chnroutes-master ]; then
if [ ! -f master.zip ]; then
downloadPackage
fi
fi
cd ./chnroutes-master
}
function downloadPackage {
wget $downloadFileAddress
unzip master.zip
}
function getFiles {
if [ -f chnroutes.py ];then
echo ‘Getting two files from internet: ip-down & ip-up’
`python chnroutes.py -p mac`
fi
}

function mvFiles {
echo ‘move files: ip-up ip-down to /etc/ppp need your passcode for.’
sudo mv ./ip-down /etc/ppp
sudo mv ./ip-up /etc/ppp
}

function cleanUp {
echo ‘clean up DONE.’
read -p ‘Do you want remove all tmp files? y|n ‘ removeALLFiles
case $removeALLFiles in
y|Y )
rm -rf $tmpDirForVpnController
;;
*)
echo ‘Do nothing. exit’
;;
esac

}

checkFiles
getFiles
mvFiles
cleanUp

echo ‘All things done, please restart your VPN client.’
echo ‘Have a nice day :)’
exit 0

EOF.