*BSD News Article 46772


Return to BSD News archive

#! rnews 6227 sserve.cc.adfa.oz.au
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!howland.reston.ans.net!agate!news.mindlink.net!vanbc.wimsey.com!news.rmii.com!rainbow!davidm
From: davidm@rainbow.rmii.com (David Martin)
Newsgroups: comp.unix.bsd.bsdi.misc
Subject: Dynamic slip/ppp works/problem
Date: 12 Jul 1995 16:37:00 GMT
Organization: Rocky Mountain Internet Inc.
Lines: 198
Message-ID: <3u0tnc$q1f@natasha.rmii.com>
NNTP-Posting-Host: rainbow.rmii.com
X-Newsreader: TIN [version 1.2 PL2]


I am working on the problem of getting BSDI to handle dynamic slip as 
well as dynamic ppp connections.  I have solved the problem of dynamic
slip, but have been unsuccesfull at getting dynamic ppp working.  I have
included my slip solution for everyone's benefit as well as my almost
working ppp solution for suggestions on how to make it work.  

The problem with ppp is the "route add" command.  Since I am tring to get 
this to work on the same subnet as the ethernet, the route command adds 
the route to the ethernet and not the ppp[0-7] device :-(  When I 
hardwire the src and dest ip's in /etc/ppp.sys everything works fine.  

Any ideas?  

The programs "dynamicslip" and "dynamicppp" are the login shells assigned
to a user.  This way I can echo to the tty what the src and dest ip's are
before the slip/ppp programs take over the tty.  This works great for
chat scripts to parse out the ip's (like Trumpet Winsock).

Note: I have changed the class C ip address to 222.222.222 as well as the 
ARP address for these examples.

----PPP STUFF----

---begin /etc/netscripts/dynamicppp---
#!/bin/sh
# dynamicppp
# Author: David Martin (davidm@large.com)
# A stub program to allow dynamicly assigned IP's under BSDI Unix.  The
# other part of this is /etc/sliphome/slip.login.

localaddr=222.222.222.1
unit=`tty`

case $unit in
	/dev/ttyA00 ) remoteaddr=222.222.222.166 ;; 
	/dev/ttyA01 ) remoteaddr=222.222.222.167 ;; 
	/dev/ttyA02 ) remoteaddr=222.222.222.168 ;; 
	/dev/ttyA03 ) remoteaddr=222.222.222.169 ;; 
	/dev/ttyA04 ) remoteaddr=222.222.222.170 ;; 
	/dev/ttyA05 ) remoteaddr=222.222.222.171 ;; 
	/dev/ttyA06 ) remoteaddr=222.222.222.172 ;; 
	/dev/ttyA07 ) remoteaddr=222.222.222.173 ;; 
esac
echo "PPP session from ($localaddr) TO $remoteaddr beginning...."
exec /usr/bin/ppp

----begin /etc/ppp.sys
Puser:\
   :di:\
   :li=/etc/netscripts/ppp.login:\
   :lu=/etc/netscripts/ppp.up:\
   :ld=/etc/netscripts/ppp.down:

----begin /etc/netscripts/ppp.login----
#!/bin/sh
# ppp.login
# Author: David Martin (davidm@large.com)

login=$1
pppunit=$2
localaddr=222.222.222.1
netmask=255.255.255.0

case $pppunit in
	ppp0 ) remoteaddr=222.222.222.166 ;; 
	ppp1 ) remoteaddr=222.222.222.167 ;; 
	ppp2 ) remoteaddr=222.222.222.168 ;; 
	ppp3 ) remoteaddr=222.222.222.169 ;; 
	ppp4 ) remoteaddr=222.222.222.170 ;; 
	ppp5 ) remoteaddr=222.222.222.171 ;; 
	ppp6 ) remoteaddr=222.222.222.172 ;; 
	ppp7 ) remoteaddr=222.222.222.173 ;; 
esac
/sbin/ifconfig $pppunit inet $localaddr $remoteaddr netmask $netmask up
logger -s -t ppp "Attached unit $pppunit for $login (remoteaddr: $remoteaddr) (speed: $speed) (args: $opt_args)"
exit 0

----begin /etc/netscripts/ppp.up----
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin
SYSTEM=$1 # System
INTERFACE=$2 # Interface
LOCAL=$3 # Local address
REMOTE=$4 # Remote address

if [ "$REMOTE" ] ; then
   route add $REMOTE $LOCAL
fi

----begin /etc/netscripts/ppp.down----
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin
SYSTEM=$1 # System
INTERFACE=$2 # Interface
LOCAL=$3 # Local address
REMOTE=$4 # Remote address

if [ "$REMOTE" ] ; then
   route delete $REMOTE
fi
if [ "$LOCAL" ] ; then
   ifconfig $INTERFACE -alias $LOCAL down
   route delete $LOCAL 127.0.0.1
fi

----SLIP STUFF, THIS WORKS GREAT!----

----begin dynamicslip----
#!/bin/sh
# dynamicslip
# Author: David Martin (davidm@large.com)
# A stub program to allow dynamicly assigned IP's under BSDI Unix.  The
# other part of this is /etc/sliphome/slip.login.

localaddr=222.222.222.1
unit=`tty`

case $unit in
	/dev/ttyA00 ) remoteaddr=222.222.222.66 ;; 
	/dev/ttyA01 ) remoteaddr=222.222.222.67 ;; 
	/dev/ttyA02 ) remoteaddr=222.222.222.68 ;; 
	/dev/ttyA03 ) remoteaddr=222.222.222.69 ;; 
	/dev/ttyA04 ) remoteaddr=222.222.222.70 ;; 
	/dev/ttyA05 ) remoteaddr=222.222.222.71 ;; 
	/dev/ttyA06 ) remoteaddr=222.222.222.72 ;; 
	/dev/ttyA07 ) remoteaddr=222.222.222.73 ;; 
esac
echo "SL/IP session from ($localaddr) TO $remoteaddr beginning...."
exec /usr/sbin/sliplogin

----begin /etc/sliphome/slip.hosts----
#
# SLIP Hosts initialization file
#
# login		localaddr	remoteaddr	netmask		opt_args
#-------	---------	----------	-------		--------
Suser		222.222.222.1	DYNAMIC		255.255.255.0	normal

----begin /etc/sliphome/slip.login----
#!/bin/sh
# slip.login
# Author: David Martin (davidm@large.com)
# Called by /usr/sbin/sliplogin.  See /etc/sliphome/dynamicslip


slipunit=$1; shift
speed=$1; shift
login=$1; shift
localaddr=$1; shift
remoteaddr=$1; shift
netmask=$1; shift
opt_args=$*;

if [ "$remoteaddr" = "DYNAMIC" ]
then
	case $slipunit in
		0 ) remoteaddr=222.222.222.66 ;; 
		1 ) remoteaddr=222.222.222.67 ;; 
		2 ) remoteaddr=222.222.222.68 ;; 
		3 ) remoteaddr=222.222.222.69 ;; 
		4 ) remoteaddr=222.222.222.70 ;; 
		5 ) remoteaddr=222.222.222.71 ;; 
		6 ) remoteaddr=222.222.222.72 ;; 
		7 ) remoteaddr=222.222.222.73 ;; 
	esac
fi
/sbin/ifconfig sl${slipunit} inet $localaddr $remoteaddr netmask $netmask up
/usr/sbin/arp -s $remoteaddr c0:80:cd:80 # made up for this example add yours 
logger -s -t slip "Attached unit $slipunit for $login (remoteaddr: $remoteaddr) (speed: $speed) (args: $opt_args)"
exit 0

----begin /etc/sliphome/slip.logout----
#!/bin/sh

slipunit=$1; shift
speed=$1; shift
login=$1; shift
localaddr=$1; shift
remoteaddr=$1; shift
netmask=$1; shift
opt_args=$*;

logger -s -t slip "Detached unit $slipunit from $login"
route delete $remoteaddr $localaddr
/usr/sbin/arp -d $remoteaddr

exit 0


--
--
David F. Martin                       | Consultants @ Large
davidm@large.com                      | 4026 S. Parker Rd., suite 112
My other system is a Linux system.    | Aurora, CO. 80014 
So is my main one :-)                 | (303) 680-8207 Fax: Please Call