wvdial
and dial-on-demand
Mainpage
Searchform
History
Versions
Categories
Contents
Deutsch
wvdial
and dial-on-demand
SuSE Linux: Version 6.3
Netscape
is asked to retrieve an external URL. It should disconnect
when the link has been idle for a certain amount of time.
root
/sbin/init.d/wvdial.dod
chmod 744 /sbin/init.d/wvdial.dod
ln -s /sbin/init.d/wvdial.dod /sbin/wvdial.dod
wvdial.dod start [subsection ...]
subsection is the name of the parameter section for your non
default provider. This is optional.
There is further information in the man-pages of wvdial
(man wvdial
) on using more providers.
Although the scrip can only be started as root
, any
user can use the connection.
wvdial.dod restart
wvdial.dod hangup
root
wvdial.dod stop
ln -s /sbin/init.d/wvdial.dod /sbin/init.d/rc2.d/S20wvdial.dod
ln -s /sbin/init.d/wvdial.dod /sbin/init.d/rc3.d/S20wvdial.dod
ln -s /sbin/init.d/wvdial.dod /sbin/init.d/rc2.d/K20wvdial.dod
ln -s /sbin/init.d/wvdial.dod /sbin/init.d/rc3.d/K20wvdial.dod
[Dialer Defaults]
will be called.
wvdial
/etc/wvdail.conf
/etc/wvdail.conf can be expanded with the following options:
Remote IP=nnn.nnn.nnn.nnn
192.168.99.99
In most cases you do
not need to change this.
Local IP=nnn.nnn.nnn.nnn
192.168.99.1
and need not to be
changed in most cases.
Idle=n
180
seconds
Defaultroute=yes|no
yes
the PPP-connection is the gateway for all
non-local connections, as is preconfigured.
Important:
In the file /etc/wvdail.conf
comments (startin with ;) may
not be used when you use the /sbin/init.d/wvdial.dod script.
#! /bin/bash
#
# Copyright (c) 1999 SuSE GmbH Nuernberg, Germany. All rights reserved.
#
#
# parameters
# start section section section
# restart section section section
# start or restart the daemon with parameters found in /etc/wvdial.conf
# section is the name of a section in the /etc/wvdial.conf file
# (see man wvdial)
# stop
# stop the pppd
# hangup
# hang up the telephone line
# additional Parameters in /etc/wvdial.conf could be
# Idle: sets the idle-time for waiting before hang up (deafult 180s)
# Remote IP: remote IP-address (default 192.168.99.99)
# Local IP: local IP-address (default 192.168.99.1)
# Defaultroute: no: pppd will not set the default route to the remote ip
# (default yes)
function setpppdparam()
{
CONFFILE="/etc/wvdial.conf"
TMPFILE="/tmp/wvdial.dod.tmp"
# extract subsection
cat /etc/wvdial.conf | sed -n "/Dialer.*$SECTION/{:x;p;n;/Dialer/q;bx}" > $TMPFILE
VALUE=`cat $TMPFILE | grep "Modem" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Modem=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Baud" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Baud=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Username" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Username=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Remote IP" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Remote_IP=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Local IP" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Local_IP=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Idle" | cut -f2 -d"="`
if [ ! -z "$VALUE" ]; then Idle=$VALUE; fi
VALUE=`cat $TMPFILE | grep "Defaultroute" | cut -f2 -d"="`
if [ X$VALUE = XNo -o X$VALUE = XNO -o X$VALUE = Xno ]; \
then DEFAULTROUTE="nodefaultroute"; fi
rm -f $TMPFILE
}
function killpppd()
{
if [ -e $PIDFILE ]; then
echo -n "killing pppd process "
PID=`cat $PIDFILE`
echo PID=$PID
kill -15 $PID 2>/dev/null
#kill -9 $PID 2>/dev/null
rm $PIDFILE
fi
}
function startpppd()
{
# set defaults, no defaults for
# Username, Modem, Baud
Local_IP="192.168.99.1"
Remote_IP="192.168.99.99"
Idle=180
DEFAULTROUTE="defaultroute"
# get params from section "Dialer Default"
SECTION=Defaults
setpppdparam
# parse given section ([Dailer xxx]) parameters
while [ ! -z $1 ]; do
SECTION=$1
setpppdparam
shift
done
# start pppd in demand mode
PPPPDPARAMS="$Local_IP:$Remote_IP $Modem $Baud modem crtscts
$DEFAULTROUTE \
-detach user $Username \
ipcp-accept-local ipcp-accept-remote call wvdial \
demand idle $Idle"
echo -n "starting pppd $PPPPDPARAMS connect \"/usr/bin/wvdial --chat $WVPARAMS\"... "
pppd $PPPPDPARAMS connect "/usr/bin/wvdial --chat $WVPARAMS" &>/dev/null &
PPPDPID=$!
echo $PPPDPID > $PIDFILE
echo PID=$PPPDPID
exit 0
}
# main
LINKNAME=dod
PIDFILE=/var/run/pppd.$LINKNAME.pid
ACTION=$1
shift
WVPARAMS=$@
case "$ACTION" in
start)
# make sure to start even when uncleanly stopped
killpppd
netstat --inet -p
startpppd $@
netstat --inet -p
;;
stop)
# handle stop
killpppd
exit 0
;;
reload|restart)
killpppd
startpppd $@
;;
hangup)
if [ -e $PIDFILE ]; then
echo -n "hangup pppd connection "
PID=`cat $PIDFILE`
echo " PID=$PID"
kill -SIGHUP $PID #2>/dev/null
exit 0
fi
echo no pppd connection
exit 1
;;
# status)
# ;;
*)
echo "Usage: /sbin/init.d/wvdial.dod {start [section [section [..]]]|hangup|stop|restart}"
exit 1
;;
esac
Keywords: MODEM, INTERNET, PPPD, WVDIAL, PROVIDER, DIALONDEMAND, DIAL-ON-DEMAND
Categories:
Network
Mainpage
Searchform
History
Versions
Categories
Contents
Deutsch