*BSD News Article 26694


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!howland.reston.ans.net!cs.utexas.edu!swrinde!menudo.uh.edu!uuneo.NeoSoft.com!nobody
From: smace@metal.neosoft.com (Scott Mace)
Newsgroups: comp.os.386bsd.questions
Subject: Re: Help PPP
Date: 28 Jan 1994 21:48:55 -0600
Organization: NeoSoft (Katy Research Center)
Lines: 286
Message-ID: <2icmbp$5hd@metal.neosoft.com>
References: <2i5plg$kpp@hk.super.net>
NNTP-Posting-Host: metal.neosoft.com

In article <2i5plg$kpp@hk.super.net>,
Charlie & <root@mwong.hk.super.net> wrote:
>
>Hello ,
>
>I am running FreeBSD 1.0 with problems using PPP. Can anyone tell me the correct
>use of PPP to link up my server ?
>
>thanks

Here's my ppp scripts:


# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	.
#	./bin
#	./bin/pppdown
#	./bin/pppdown.soft
#	./bin/pppmaintain
#	./bin/ppptest
#	./bin/pppup
#	./etc
#	./etc/kermit.dial
#	./etc/kermit.hup
#
echo c - .
mkdir . > /dev/null 2>&1
echo c - ./bin
mkdir ./bin > /dev/null 2>&1
echo x - ./bin/pppdown
sed 's/^X//' >./bin/pppdown << 'END-of-./bin/pppdown'
X#!/bin/sh
Xps ax |grep pppd |grep -v grep
Xpid=`ps ax |grep pppd |grep -v grep |grep -v pppdown |awk '{print $1;}'`
Xif [ "X${pid}" != "X" ] ; then
X	echo -n 'killing pppd, PID=' ${pid}
X        kill -9 ${pid}
Xfi
Xecho 'done.'
Xecho -n 'deleting interface...'
X/sbin/ifconfig ppp0 delete
Xecho 'done.'
X#echo 'flushing routes:'
X#/sbin/route flush
Xecho 'done.'
Xecho -n 'setting modem clocal...'
Xstty -f /dev/sio00 clocal
Xecho 'done.'
X
Xkermit -y /root/etc/kermit.hup </dev/null
END-of-./bin/pppdown
echo x - ./bin/pppdown.soft
sed 's/^X//' >./bin/pppdown.soft << 'END-of-./bin/pppdown.soft'
X#!/bin/sh -x
Xpid=`ps ax |grep pppd |grep -v "grep pppd" |awk '{print $1;}'`
Xif [ X${pid} != "X" ] ; then
X	echo -n 'killing pppd, PID=' ${pid}
Xkill -9 ${pid}
Xfi
Xecho 'done.'
X
END-of-./bin/pppdown.soft
echo x - ./bin/pppmaintain
sed 's/^X//' >./bin/pppmaintain << 'END-of-./bin/pppmaintain'
X#!/bin/sh
X# pppmaintain
Xremoteip=XXX.XXX.XXX.XXX
X
Xexec >/root/ppp.log 2>&1
Xwhile true; do
X  if ping -c 1 $remoteip |grep -s '0 packets received' ; then
X    echo -n ppp is down. ""
X    date
X    ping -c 1 $remoteip
X    sh /root/bin/ppptest
X    netstat -n -s
X    sh /root/bin/pppup
X  else
X    echo -n ppp is up. ""
X    date
X  fi
X  sleep 600
Xdone
END-of-./bin/pppmaintain
echo x - ./bin/ppptest
sed 's/^X//' >./bin/ppptest << 'END-of-./bin/ppptest'
X#!/bin/sh
Xpid=`ps ax| grep pppd |grep -v grep|awk '{print $1;}'`
Xif [ X${pid} != "X" ] ; then
X	echo 'pppd running: PID=' ${pid-NONE}
Xelse
X	echo 'No pppd running.'
Xfi
Xset -x
Xnetstat -n -I ppp0
Xifconfig ppp0
END-of-./bin/ppptest
echo x - ./bin/pppup
sed 's/^X//' >./bin/pppup << 'END-of-./bin/pppup'
X#!/bin/sh 
Xremoteip=XXX.XXX.XXX.XXX
Xlocalip=XXX.XXX.XXX.XXX
Xps ax |grep pppd |grep -v grep
Xpid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
Xif [ "X${pid}" != "X" ] ; then
X	echo 'killing pppd, PID=' ${pid}
X	kill ${pid}
Xfi
Xps ax |grep kermit |grep -v grep
Xpid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
Xif [ "X${pid}" != "X" ] ; then
X	echo 'killing kermit, PID=' ${pid}
X	kill -9 ${pid}
Xfi
X/usr/local/bin/kermit -y /root/etc/kermit.dial </dev/null
X
Xecho -n 'starting ppp daemon...'
X/usr/libexec/pppd crtscts mru 1500 netmask 255.255.255.0 /dev/sio00 38400 $localip:$remoteip
Xsleep 10
Xecho 'done.'
Xecho 'add routes:'
Xroute add default $remoteip
Xroute add $localip localhost
Xroute add $remoteip $localip
Xecho 'done.'
Xecho 'PPP is up.'
END-of-./bin/pppup
echo c - ./etc
mkdir ./etc > /dev/null 2>&1
echo x - ./etc/kermit.dial
sed 's/^X//' >./etc/kermit.dial << 'END-of-./etc/kermit.dial'
X;
X; put the com line attached to the modem here:
X;
Xset line /dev/sio00
X;
X; put the modem speed here:
X;
Xset speed 38400
X;set file type binary		; full 8 bit file xfer
X;set file names literal
X;set win 8
X;set rec pack 1024
X;set send pack 1024
X;set block 3
Xset term bytesize 8
Xset command bytesize 8
Xset flow rts
Xset modem hayes
Xset dial hangup off
Xset carrier auto		; Then SET CARRIER if necessary,
Xset dial display on		; Then SET DIAL if necessary,
Xset input echo on
Xset input timeout proceed
Xset input case ignore
Xdef \%x 0			; login prompt counter
Xgoto slhup
X
X:pppinit
Xecho Setting ignore DTR
Xoutput at&d0\13
Xinput 1 OK\13\10
Xgoto sldial
X
X:slcmd				; put the modem in command mode
Xecho Put the modem in command mode.
Xclear				; Clear unread characters from input buffer
Xpause 1
Xoutput +++			; hayes escape sequence
Xinput 1 OK\13\10		; wait for OK
Xif success goto slhup
Xoutput \13
Xpause 1
Xoutput at\13
Xinput 1 OK\13\10
Xif fail goto slcmd		; if modem doesn't answer OK, try again
X
X:slhup				; hang up the phone
Xclear				; Clear unread characters from input buffer
Xpause 1
Xecho Hanging up the phone.
Xoutput ath0\13			; hayes command for on hook
Xinput 2 OK\13\10
Xif fail goto slcmd		; if no OK answer, put modem in command mode
Xgoto pppinit
X
X:sldial				; dial the number
Xpause 4
Xecho Dialing.
Xoutput atdt9999999\13\10	; put phone number here
Xassign \%x 0			; zero the time counter
X
X:look
Xclear				; Clear unread characters from input buffer
Xincrement \%x			; Count the seconds
Xinput 20 {CONNECT }
Xif success goto sllogin
Xreinput 1 {BSDI } 
Xif success goto sllogin
Xreinput 1 {NO CARRIER\13\10}
Xif success goto sldial
Xreinput 1 {NO DIALTONE\13\10}
Xif success goto slnodial
Xreinput 1 {\255}
Xif success goto slhup
Xreinput 1 {\127}
Xif success goto slhup
Xif < \%x 60 goto look
Xelse goto slhup
X
X:sllogin			; login
Xassign \%x 0			; zero the time counter
Xpause 1
Xecho Looking for login prompt.
X
X:slloop
Xincrement \%x			; Count the seconds
Xclear				; Clear unread characters from input buffer
Xoutput \13
X;
X; put your expected login prompt here:
X;
Xinput 1 {login: }
Xif success goto sluid
Xreinput 1 {\255}
Xif success goto slhup
Xreinput 1 {\127}
Xif success goto slhup
Xif < \%x 10 goto slloop		; try 10 times to get a login prompt
Xelse goto slhup			; hang up and start again if 10 failures
X
X:sluid
X;
X; put your userid here:
X;
Xoutput XXXXXXXX\13
Xinput 1 {password: }
X;
X; put your password here:
X;
Xoutput XXXXXXX
X;input 1 {Packet mode enabled}
Xecho
Xquit
X
X:slnodial
Xecho \7No dialtone.  Check the telephone line!\7
Xexit 1
X
X; local variables:
X; mode: csh
X; comment-start: "; "
X; comment-start-skip: "; "
X; end:
END-of-./etc/kermit.dial
echo x - ./etc/kermit.hup
sed 's/^X//' >./etc/kermit.hup << 'END-of-./etc/kermit.hup'
Xset line /dev/sio00
Xset speed 38400
X;set file type binary
X;set file names literal
X;set win 8
X;set rec pack 1024
X;set send pack 1024
X;set block 3
Xset term bytesize 8
Xset command bytesize 8
Xset flow rts
X
Xpau 1
Xout +++
Xinp 10 {NO CARRIER}
Xreinp 5 {OK}
Xout ATH0&D2\13
Xecho \13
Xexit
X
END-of-./etc/kermit.hup
exit