Created
August 3, 2014 05:58
-
-
Save akasfei/4e2cfbf70022598f018d to your computer and use it in GitHub Desktop.
VPN route for Android L
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
#!/system/bin/sh | |
# VPN_SERVER_IP is the real ip of vpn server | |
VPN_SERVER_IP="173.255.216.157" | |
# Name of virtual interface name, default: ppp0 | |
# Unneccessary to change | |
VPN_IF_NAME="ssiops" | |
DEFAULT_ROUTE=$( ip route show table all | grep -e '^default' | grep -v $VPN_IF_NAME ) | |
DEFAULT_TABLE_ID=$( echo $DEFAULT_ROUTE | sed -n 's/.*table\s*\([0-9]*\)/\1/p' ) | |
DEFAULT_DEV=$( echo $DEFAULT_ROUTE | sed -n 's/.*dev\s*\([0-9a-zA-Z]*\).*/\1/p' ) | |
DEFAULT_GW=$( echo $DEFAULT_ROUTE | sed -n 's/.*\s\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p' ) | |
DNS1=$( getprop | grep net.dns1 | sed -n 's/.*\[\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p' ) | |
DNS2=$( getprop | grep net.dns2 | sed -n 's/.*\[\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p' ) | |
echo "Default route is \"$DEFAULT_ROUTE\"" | |
echo "Default table_id is \"$DEFAULT_TABLE_ID\"" | |
echo "Default dev is \"$DEFAULT_DEV\"" | |
echo "Default gw is \"$DEFAULT_GW\"" | |
echo | |
ip route del default table $DEFAULT_TABLE_ID | |
ip route add $VPN_SERVER_IP via $DEFAULT_GW dev $DEFAULT_DEV | |
ip route add $DNS1 via $DEFAULT_GW dev $DEFAULT_DEV | |
ip route add $DNS2 via $DEFAULT_GW dev $DEFAULT_DEV | |
ip route add default dev $VPN_IF_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment