Skip to content

Instantly share code, notes, and snippets.

@jackyyf
Created July 20, 2015 08:37
Show Gist options
  • Save jackyyf/0802ce18a9302861ccde to your computer and use it in GitHub Desktop.
Save jackyyf/0802ce18a9302861ccde to your computer and use it in GitHub Desktop.
Gist by paste.py @ 2015-07-20 16:37:49.741682
#!/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
#!/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