You are not logged in.

#1 2010-05-01 17:33:46

mapster
Member
Registered: 2009-06-03
Posts: 31

ppp tunnel up/down script [Solved]

I've set up a ppp connection so that I can connect to my university's vpn and it works nicely smile
So I want to run a script when the connection is up and another when the connection is down, for setting the routes (for tunneling). I found a script for this on the webpage of pppclient, and I tried putting it in the /etc/ppp/ip-up.d/ folder, where there already was a script for setting the dns ("00-dns.sh"), which seems to work because when I set up the connection ($ pon myCon) resolv.conf gets the vpn's dns. But the script I found does not seem to run, I named it "01-tunnel.sh". Both script has 755 mode.

Anyone have some tips?

edit:
btw, here is the up script...

#!/bin/sh
# pppd ip-up script for all-to-tunnel routing

# name of primary network interface (before tunnel)
PRIMARY=wlan0

# address of tunnel server
SERVER=vpn-server

# 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 ${TUNNEL}

fi

Last edited by mapster (2010-05-02 19:48:31)

Offline

#2 2010-05-01 18:39:58

Sin.citadel
Member
Registered: 2008-01-22
Posts: 267

Re: ppp tunnel up/down script [Solved]

try checking the /etc/ppp/ip-up script, although your script should work because by default all scripts *.sh in ip-up.d files are run after a successful connection. try adding the script to the ip-up script itself if it doesnt work.

Offline

#3 2010-05-02 00:23:28

mapster
Member
Registered: 2009-06-03
Posts: 31

Re: ppp tunnel up/down script [Solved]

checked that the scipts run by making them output what they do to a file. And they execute what they should, but somehow all the route executions gets ignored or overrun lateron :S when the scripts run they have the necessary rights to execute route too....

Offline

#4 2010-05-02 08:14:55

Sin.citadel
Member
Registered: 2008-01-22
Posts: 267

Re: ppp tunnel up/down script [Solved]

yes, the route problem that you have is because ppp needs the full path to execute those commands, try replacing route with /sbin/route, it should work fine then.

Offline

#5 2010-05-02 11:49:30

mapster
Member
Registered: 2009-06-03
Posts: 31

Re: ppp tunnel up/down script [Solved]

Ahhh... Thanks big_smile
That did the trick smile

Offline

Board footer

Powered by FluxBB