EXAMPLES
If you run ppp in -auto mode, pppctl can be used to automate many frequent tasks (you can actually control ppp in any mode except interactive mode). Use of the -p option is discouraged (even in scripts that are not readable by others) as a ps(1) listing may reveal your secret. The best way to allow easy, secure pppctl access is to create a local server socket in /etc/ppp/ppp.conf (in the correct section) like this:
set server /var/run/internet "" 0177
This will instruct ppp to create a local domain socket, with srw------- permissions and no password, allowing access only to the user that invoked ppp. Refer to the ppp(8) man page for further details.
You can now create some easy-access scripts. To connect to the internet:
#! /bin/sh
test $# -eq 0 && time=300 || time=$1
exec pppctl /var/run/internet set timeout $time\; dial
To disconnect:
#! /bin/sh
exec pppctl /var/run/internet set timeout 300\; close
To check if the line is up:
#! /bin/sh
pppctl -p -v /var/run/internet quit | grep ^PPP >/dev/null
if [ $? -eq 0 ]; then
echo Link is up
else
echo Link is down
fi
You can even make a generic script:
#! /bin/sh
exec pppctl /var/run/internet "$@"
You could also use pppctl to control when dial-on-demand works. Suppose you want ppp to run all the time, but you want to prevent dial-out between 8pm and 8am each day. However, any connections active at 8pm should continue to remain active until they are closed or naturally time out.
A cron(8) entry for 8pm which runs
pppctl /var/run/internet set filter dial 0 deny 0 0
will block all further dial requests, and the corresponding 8am entry
pppctl /var/run/internet set filter dial -1
will allow them again.
SEE ALSO
ps(1), editline(3), editrc(5), services(5), ppp(8)
HISTORY