Last active
January 25, 2021 04:34
-
-
Save vkushnir/3d9f7121baddd0a03dc5e441ae37781d to your computer and use it in GitHub Desktop.
A script for PPTP custom routing on VPNs
This file contains hidden or 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
#!/bin/sh | |
# When the ppp link comes up, this script is called with the following | |
# parameters | |
# $1 the interface name used by pppd (e.g. ppp3) | |
# $2 the tty device name | |
# $3 the tty device speed | |
# $4 the local IP address for the interface | |
# $5 the remote IP address | |
# $6 the parameter specified by the 'ipparam' option to pppd | |
DEBUGFILE=/tmp/ip-up-debug.txt | |
## echo "1:$1 2:$2 3:$3 4:$4 5:$5 6:$6" > $DEBUGFILE | |
NET=`echo $5 | cut -d. -f1,2,3` | |
## echo $NET >> $DEBUGFILE | |
case $NET in 192.168.3) | |
## echo "CASE1" >> $DEBUGFILE | |
RESULT=`/sbin/route add -net 192.168.30.0 $5 255.255.255.0` | |
##echo $RESULT >> $DEBUGFILE | |
;; | |
192.168.2) | |
## echo "CASE2" >> $DEBUGFILE | |
RESULT=`/sbin/route add -net 192.168.20.0 netmask 255.255.255.0 gw $5` | |
## echo $RESULT >> $DEBUGFILE | |
;; | |
192.168.1) | |
## echo "CASE3" >> $DEBUGFILE | |
RESULT=`/sbin/route add -net 192.168.10.0 netmask 255.255.255.0 gw $5` | |
## echo $RESULT >> $DEBUGFILE | |
;; | |
*) | |
## echo "No match" >> $DEBUGFILE | |
;; | |
esac | |
# /etc/ppp/ip-up | |
# http://hints.macworld.com/article.php?story=20060216061850917 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment