[pptp-server] linux pptp client: how to stop it?

Gord Belsey gord at amador.ca
Thu Jul 27 15:25:40 CDT 2000


Dave:

Tom's script is similar to what I'm doing, except a whole lot cleaner (and
only one, rather than 3)!  I've added my two cent's in line:

Gord
----- Original Message -----
From: Dave Morse <svref at yahoo.com>
To: Tom Eastep <teastep at evergo.net>
Cc: Dave Morse <svref at yahoo.com>; <pptp-server at lists.schulte.org>
Sent: Thursday, July 27, 2000 11:13 AM
Subject: Re: [pptp-server] linux pptp client: how to stop it?


> Tom Eastep writes:
>  > Thus spoke Dave Morse:
>  >
>  > > I have the linux pptp client working.  Now how do I get it to shut
down
>  > > and free ppp0?  This is so that I can start it again, after a remote
>  > > server reboot or something.
>  > >
>  >
>  > Here's the script that I use:
>  > [THUNK]
>  > This is RedHat-centric but can be adapted to other setups.
>
> Lucky for me, since RH is what the server happens to use.  I had to modify
> the script a bit.  There were a few hacks in it, that maybe people can
> clear up.
>
> Here are the particular hacks:
>
> 1) it checks for the success of pptp by greping for "ppp0" in "ifconfig".
> Unfortunately it takes some time for pptp to actually create ppp0 on my
> configuration.  So I have to "sleep 5" in there.  Ideally I could query
> the state, to see if the connection has been accepted, failed, or still
> resolving.
>
> 2) This variant script assumes ppp0 is the interface that gets created.
> Can anyone think of a good way to query the created interface?  Better
> yet, can anyone think of a way to force ppp0?  This makes firewall admin
> cleaner.
>
The ppp interface used is put into /var/run/ppp-<user>.dev when the
interface comes up...you can get it from there.  Not sure about forcing the
interface to ppp0.  I use ipchains for the firewall, so I use ppp+ rather
than ppp0 as the interface in related rules statements.(in my case all ppp
interfaces are for pptp).

> 3) This script calls route after a successful connect, to interface to the
> whole subnet on the other side of the connection.

Like Tom, I use ip-up.local to add the route.  I also del the route in
ip-down.local.
>
> #!/bin/sh
> #
> #  /etc/rc.d/init.d/wet-vpn
> #
> # chkconfig: 5 12 85
> # description: PPTP Link Control
> #
>
> PPTP=/usr/local/sbin/pptp
> # Tunnel_name identifies the network we're dealing with.  Intended to
> # match the filename of this script in /etc/rc.d/init.d/
> TUNNEL_NAME=wet-vpn
> # External internet interface of the vpn-ing machine
> ADDRESS=209.85.130.149
> # internal interface & mask that we're trying to get to.
> SUBNET=192.168.1.0
> SUBNET_MASK=255.255.255.0
> USER=pisati
> # I HOPE this is the interface we get. :(
> # I've not found the flags to FORCE it to be this, but this is where
> # we'll go a-file-freeing to turn things off.
> INTERFACE=ppp0
>
> case "$1" in
> start)
> echo "Starting PPTP Connection to ${TUNNEL_NAME}..."
> $PPTP $ADDRESS user $USER
> echo "Sleeping for login to resolve"
> sleep 5
> if `ifconfig | grep -q $INTERFACE` ; then
> touch /var/lock/subsys/$TUNNEL_NAME
> echo "Setting up routing through $INTERFACE"
> route add -net $SUBNET netmask $SUBNET_MASK dev $INTERFACE
> else
> echo "Something went wrong  no $INTERFACE found in ifconfig output"
>                 fi
> ;;
> stop)
> echo "Stopping $TUNNEL_NAME PPTP Connection..."
> if ( /usr/bin/killall $PPTP ); then
>     echo "Stopped pptp"
> else
>     rm -f /var/run/pptp/$ADDRESS
>                 fi
>
> if ( /usr/bin/killall pppd ); then
>     echo "Stopped pppd"
>                 fi
> rm -f /var/lock/subsys/$TUNNEL_NAME
>
> echo taking $INTERFACE down
> ifconfig $INTERFACE down
>
> sleep 5
> ;;
> restart)
> echo "Restarting $TUNNEL_NAME PPTP Connection..."
> $0 stop
> $0 start
> ;;
> status)
> ifconfig ppp0
> ;;
> *)
> echo "Usage: $0 {start|stop|restart|status}"
> ;;
> esac
> _______________________________________________
> pptp-server maillist  -  pptp-server at lists.schulte.org
> http://lists.schulte.org/mailman/listinfo/pptp-server
> List services provided by www.schulteconsulting.com!




More information about the pptp-server mailing list