Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to provide VPN split routing via PPPTP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to provide VPN split routing via PPPTP
Authored by: carbon14 on Dec 08, '03 02:52:18AM

This script worked for me, but I had to change a few things to make it work. Here is the new script:

#!/bin/bash
################################################################################
# FIX VPN ROUTING . SH
# Author: Daniel Giribet
# Improvement over shell script published by 'Anonymous' on macosxhints.com
# 'silas' perl script did not work for me, so I use this one.
# Though the scipt is trivial, use at your own risk.
#
# 12/7/03 - modified by carbon14
# fixed mask to be derived from local ip
# fixed mask sed script. You can alter the mask size by changing "$3" to 0

PPP_LOG=/tmp/ppp.log

default_=$(/usr/sbin/netstat -nr | grep ' UHLW ' | awk '{print $1}')
remote_vpn_str=$(/usr/bin/tail -5 $PPP_LOG|/usr/bin/grep 'remote IP address')
local_vpn_str=$(/usr/bin/tail -5 $PPP_LOG|/usr/bin/grep 'local IP address')
n=$(echo $remote_vpn_str |/usr/bin/wc -w|/usr/bin/tr -d 'n' |/usr/bin/tr -d ' ')
remote_vpn=$(echo $remote_vpn_str | awk '{print $'$n'}')
local_vpn=$(echo $local_vpn_str | awk '{print $'$n'}')
mask=$(echo $local_vpn|/usr/bin/sed -e 's/\./ /g' | awk '{print $1"."$2"."$3".0"}')

/usr/bin/logger 'fix_vpn_routing.sh: modifying routes...'

/sbin/route delete default $remote_vpn
/sbin/route add default $default_
/sbin/route add $mask $remote_vpn

/usr/bin/logger "fix_vpn_routing.sh: default: $default_ mask: $mask"


There was a problem with the sed script not having the proper escape for "."

You can also modify the size of the mask by removing the "$3" and setting it to 0

-Carbon14



[ Reply to This | # ]