#!/bin/sh # pppd ip-up script for all-to-tunnel routing # address of tunnel server SERVER=$5 if [ "${SERVER}" = "" ]; then SERVER=${PPP_REMOTE}; fi PRIMARY=`/sbin/route -n|awk '/^0\.0\.0\.0/ {print $8}'` echo "$PRIMARY" > /tmp/default_interface #echo "Interface $PRIMARY" # provided by pppd: string to identify connection aka ipparam option CONNECTION=$6 if [ "${CONNECTION}" = "" ]; then CONNECTION=${PPP_IPPARAM}; fi # provided by pppd: interface name TUNNEL=$1 if [ "${TUNNEL}" = "" ]; then TUNNEL=${PPP_IFACE}; fi # if we are being called as part of the tunnel startup if [ "${CONNECTION}" = "tunnel" ] ; then # direct tunnelled packets to the tunnel server route add -host ${SERVER} dev ${PRIMARY} # direct all other packets into the tunnel route del default ${PRIMARY} route add default dev ${PPP_IFACE} fi