Skip to content

Instantly share code, notes, and snippets.

@int128
Created July 5, 2014 13:07
Show Gist options
  • Save int128/cc2b5f0bc3bd35aae7b1 to your computer and use it in GitHub Desktop.
Save int128/cc2b5f0bc3bd35aae7b1 to your computer and use it in GitHub Desktop.
/etc/ppp/ip-up.d/1000-policyroute.sh
#!/bin/sh
#
# This script is called with the following arguments:
# Arg Name Example
# $1 Interface name ppp0
# $2 The tty ttyS1
# $3 The link speed 38400
# $4 Local IP number 12.34.56.78
# $5 Peer IP number 12.34.56.99
pppIfName=$1
pppTty=$2
pppIp=$4
pppPeerIp=$5
# ignore dial-up line.
[ $pppTty ] && exit
# duplicate routing table
#ip route list table main | egrep -v '^default' | while read line
#do
# ip route add $line table $pppIfName
#done
# flush routing table
ip route flush table $pppIfName
# add the route in the ppp-specific table
ip route add $pppIp dev $pppIfName table $pppIfName
ip route add $pppPeerIp via $pppIp table $pppIfName
ip route add default via $pppIp table $pppIfName
# remove the route in the main/local table
ip route del $pppPeerIp table main
ip route del $pppIp table local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment