Technical article 111201

Automatically changing default route for manual bringup PPP link with dynamic IP addresses.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

A manual bringup outgoing PPP link is set up according to the
instructions given in ta109485, "How to manually configure SCO
PPP for incoming/outgoing connections."  When pppattach is used
to bring up the link, it dials, connects, logs in, and then
immediately disconnects. Or, it stays connected but is not able
to communicate with other systems on the Internet.  I can connect
to my modem and then dial out and log in without getting
disconnected, so this is not a modem or UUCP problem.

How can my system's default route be automatically updated when a manual bringup outgoing PPP link (non-Morning Star PPP) uses dynamically assigned IP addresses?

Solution

You can use the shell script /etc/ppphook.sh to update the default
route. A sample /etc/ppphook.sh that is configured to do this
is attached below.
#!/bin/sh
#      @(#) ppphook.sh,v 6.1.2.2 1996/01/25 22:33:47 brad Exp
#
# Copyrighted as an unpublished work.
# (c) Copyright 1996 Computer Associates International, Inc.
# All rights reserved.
#
# RESTRICTED RIGHTS
#
# These programs are supplied under a license.  They may be used,
# disclosed, and/or copied only as permitted under such license
# agreement.  Any copy must contain the above copyright notice and
# this restricted rights notice.  Use, copying, and/or disclosure
# of the programs is strictly prohibited unless otherwise provided
# in the license agreement.
#
# This script is called from pppd with the following arguments when a link
# goes up or down:  event ifname old_src old_dst new_src new_dst
#
# Where event is "up", "down", "add", or "delete", ifname is the interface
# name, and the remaining 4 arguments are the old and new IP addresses
# in dotted decimal notation.
#
# This is a general example shell script which will rewrite static routes
# to the interface if the address changes.  Note that pppd will wait for
# this script to complete before continuing.
#
loglevel=debug

if [ $# -lt 6 ] then logger -t ppphook.sh -p $loglevel "wrong number of arguments" exit 1; fi

event=$1; ifname=$2; old_src=$3; old_dst=$4; new_src=$5; new_dst=$6
#logger -t ppphook.sh -p $loglevel "interface $ifname $event $3 $4 $5 $6"
case $event in
    down)
logger -t ppphook.sh -p $loglevel "down"
        route delete default
if [ -x /etc/rc2.d/S99route ]
        then
            sh /etc/rc2.d/S99route
fi
exit 0;;
    add)
logger -t ppphook.sh -p $loglevel "add"
if netstat -rn | grep "^default"
then
    route delete default
fi
route add default $5 | logger -t ppphook.sh -p $loglevel
exit 0;;
    up|delete)
echo "$old_src vs $new_src" | logger -t ppphook.sh -p $loglevel
if [ "$old_src" != "$new_src" ]
then
    # change static ("S") routes which point to old_src and ifname
    netstat -rn | awk '
$6 == "'$ifname'" && $2 == "'$old_src'" && index($3, "S") \
    { print "route change " $1 " '$new_src'" }' |
sh | logger -t ppphook.sh -p $loglevel
echo route delete default | sh | logger -t ppphook.sh -p $loglevel
echo route add default $6 | sh | logger -t ppphook.sh -p $loglevel
fi
if [ "$event" = "delete" ]
then
            route delete default
            if [ -x /etc/rc2.d/S99route ]
    then
        /etc/rc2.d/S99route
            fi
fi
exit 0;;
    *)
logger -t ppphook.sh -p $loglevel "unknown event: $event"
exit 1;;
esac
exit 2
NOTE:     The ppphook.sh shell script in this Technical Article was kindly
          submitted by Barry Sandever of ISIS Incorporated.

See also

ta109485, "How to manually configure SCO PPP for incoming/outgoing connections."

ta107563, "How to configure an outgoing PPP connection with IP address negotiation."

ta105903 "How do I configure my 5.0.x server as a gateway?"

ta107704 "What is SLS OSS449F Network Maintenance Supplement?"

From the Xinuos technical article database, record 111201. Reproduced with permission. The original is at www.sco.com/ta/111201, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.