Posts Tagged ‘shell’

Using route to fuck gfw!

Posted: March 16, 2011 in GFW, Uncategorized
Tags: ,

You can use route command to smart your vpn traffic.

add some rules to your pptp /etc/ppp/ip-up:

export PATH="/bin:/sbin:/usr/sbin:/usr/bin"

LOCALGATEWAY=`netstat -nr | grep '^default' | grep -v 'ppp' | sed 's/default *([0-9.]*) .*/1/'`

if [ ! -e /tmp/pptp_localgateway ]; then
    echo "${LOCALGATEWAY}" > /tmp/pptp_localgateway

dscacheutil -flushcache

route add 1.12.0/14 "${LOCALGATEWAY}"
route add 1.24.0/13 "${LOCALGATEWAY}"
route add 1.45.0/16 "${LOCALGATEWAY}"

and /etc/ppp/ip-down:

export PATH="/bin:/sbin:/usr/sbin:/usr/bin"

if [ ! -e /tmp/pptp_localgateway ]; then
        exit 0

LOCALGATEWAY=`cat /tmp/pptp_localgateway`

route delete 1.12.0/14 ${LOCALGATEWAY}
route delete 1.24.0/13 ${LOCALGATEWAY}
route delete 1.45.0/16 ${LOCALGATEWAY}
route delete 1.48.0/14 ${LOCALGATEWAY}

rm /tmp/pptp_localgateway

Notice: Do not forget to add 192.168.0/16 to your local gateway(maybe eth0, ppp0 for vpn gateway)