Subject: Re: Using ppp on demand
To: None <darcy@druid.net>
From: maximum entropy <entropy@zippy.bernstein.com>
List: current-users
Date: 03/17/1999 10:03:38
>Date: Wed, 17 Mar 1999 08:28:25 -0500 (EST)
>From: "D'Arcy" "J.M." Cain <darcy@druid.net>
>[...]
>Since this provider, like most, has more than one terminal server, I don't
>know what IP to give the pppd command so I can't set up demand dialing.
>If I use the demand option it complains that I haven't specified the
>remote system.  I tried giving it 0.0.0.0 as the remote system but it
>still complained.
>[...]

I had to set up something like this recently.  In my case it's a
system that needs to be able to reach exactly one host via a
demand-dialed dynamically addressed ppp link.

In this example, I will use "target" for the host name to which I'm
connecting, "192.168.0.1" as target's IP address, and "9,18005550101" as
the dialup number.

The basic idea here is that I set up a route to the intended target,
using a bogus local address on net 10, and with the target specified
as the dialup router's IP address (in reality, it isn't).

When the link is activated by traffic to the target node, the
ipcp-accept-local and ipcp-accept-remote flags let the dialed router
change both values.  The ip-up script is passed the dialed router's
real address as a parameter, so at that point I delete the bogus route
and add a real route to the target node through that router.

When the link times out, the route through the old router hangs
around.  On the next activation, the ip-up script changes the route
again to the newly dialed router.

This could probably be modified to do what you want, but you'll need
to add the "defaultroute" option, and delete/add the route to default
instead of 192.168.0.1.

--- FILE /etc/ppp/peers/target:

tty00 38400
noauth
crtscts
lock
demand
10.0.0.1:192.168.0.1
ipcp-accept-local
ipcp-accept-remote
idle 600
connect '/usr/sbin/chat -v -f /etc/ppp/chat-target'

--- FILE /etc/ppp/chat-target:

ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
ABORT "BUSY"
"" "ATE1Q0"
OK "AT&D2&C1"
OK "ATDT 9,18005550101"
CONNECT ""

--- FILE /etc/ppp/ip-up:

#! /bin/sh

iface="$1"
tty="$2"
speed="$3"
local="$4"
remote="$5"
ipparam="$6"

/bin/echo /etc/ppp/ip-up: iface="$iface" tty="$tty" speed="$speed" local="$local" remote="$remote" ipparam="$ipparam" > /dev/console 2>&1
/sbin/route delete -host 192.168.0.1 > /dev/console 2>&1
/sbin/route add -host 192.168.0.1 -iface "$local" > /dev/console 2>&1

--- FILE /etc/ppp/ip-down:

#! /bin/sh

iface="$1"
tty="$2"
speed="$3"
local="$4"
remote="$5"
ipparam="$6"

/bin/echo /etc/ppp/ip-down: iface="$iface" tty="$tty" speed="$speed" local="$local" remote="$remote" ipparam="$ipparam" > /dev/console 2>&1

--- FILE /etc/rc.local:

#       $NetBSD: rc.local,v 1.22 1997/08/29 10:29:07 veego Exp $
#       originally from: @(#)rc.local   8.3 (Berkeley) 4/28/94
#
# This file is (nearly) the last thing invoked by /etc/rc during a
# normal boot.
# It is intended to be edited locally to add site-specific boot-time
# actions, such as starting locally installed daemons.
#

echo -n 'starting local daemons:'

# add your local daemons here, following the startup models in /etc/rc

#if [ -f /usr/local/sbin/sshd ]; then
#       echo -n ' sshd'; /usr/local/sbin/sshd
#fi

if [ -f /usr/sbin/pppd ]; then
        echo -n 'pppd(target)'; /usr/sbin/pppd call target
fi

echo '.'

Cheers,
entropy

--
entropy -- it's not just a good idea, it's the second law.