3 ## 18.3 Using Kernel PPP
\r
5 ***Parts originally contributed by Gennady B. Sorokopud and Robert Huff. ***
\r
7 ### 18.3.1 Setting Up Kernel PPP
\r
9 Before you start setting up PPP on your machine, make sure that `pppd` is located in `/usr/sbin` and the directory `/etc/ppp` exists.
\r
11 `pppd` can work in two modes:
\r
13 1. As a ***client*** -- you want to connect your machine to the outside world via a PPP serial connection or modem line.
\r
14 1. As a ***server*** -- your machine is located on the network, and is used to connect other computers using PPP.
\r
16 In both cases you will need to set up an options file (`/etc/ppp/options` or `~/.ppprc` if you have more than one user on your machine that uses PPP).
\r
18 You will also need some modem/serial software (preferably [`comms/kermit`](http://pkgsrc.se/comms/kermit)), so you can dial and establish a connection with the remote host.
\r
20 ### 18.3.2 Using `pppd` as a Client
\r
22 ***Based on information provided by Trev Roydhouse. ***
\r
24 The following `/etc/ppp/options` might be used to connect to a Cisco terminal server PPP line.
\r
27 crtscts # enable hardware flow control
\r
28 modem # modem control line
\r
29 noipdefault # remote PPP server must supply your IP address
\r
30 # if the remote host does not send your IP during IPCP
\r
31 # negotiation, remove this option
\r
32 passive # wait for LCP packets
\r
33 domain ppp.foo.com # put your domain name here
\r
35 :<remote_ip> # put the IP of remote PPP host here
\r
36 # it will be used to route packets via PPP link
\r
37 # if you didn't specified the noipdefault option
\r
38 # change this line to <local_ip>:<remote_ip>
\r
40 defaultroute # put this if you want that PPP server will be your
\r
46 1. Dial to the remote host using **kermit** (or some other modem program), and enter your user name and password (or whatever is needed to enable PPP on the remote host).
\r
47 1. Exit **kermit** (without hanging up the line).
\r
48 1. Enter the following:
\r
50 # /usr/src/usr.sbin/pppd.new/pppd `***/dev/tty01***` `***19200***`
\r
52 Be sure to use the appropriate speed and device name.
\r
54 Now your computer is connected with PPP. If the connection fails, you can add the `debug` option to the `/etc/ppp/options` file, and check console messages to track the problem.
\r
56 Following `/etc/ppp/pppup` script will make all 3 stages automatic:
\r
60 ps ax |grep pppd |grep -v grep
\r
61 pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
\r
62 if [ "X${pid}" != "X" ] ; then
\r
63 echo 'killing pppd, PID=' ${pid}
\r
66 ps ax |grep kermit |grep -v grep
\r
67 pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
\r
68 if [ "X${pid}" != "X" ] ; then
\r
69 echo 'killing kermit, PID=' ${pid}
\r
74 ifconfig ppp0 delete
\r
76 kermit -y /etc/ppp/kermit.dial
\r
77 pppd /dev/tty01 19200
\r
80 `/etc/ppp/kermit.dial` is a **kermit** script that dials and makes all necessary authorization on the remote host (an example of such a script is attached to the end of this document).
\r
82 Use the following `/etc/ppp/pppdown` script to disconnect the PPP line:
\r
86 pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
\r
87 if [ X${pid} != "X" ] ; then
\r
88 echo 'killing pppd, PID=' ${pid}
\r
92 ps ax |grep kermit |grep -v grep
\r
93 pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
\r
94 if [ "X${pid}" != "X" ] ; then
\r
95 echo 'killing kermit, PID=' ${pid}
\r
99 /sbin/ifconfig ppp0 down
\r
100 /sbin/ifconfig ppp0 delete
\r
101 kermit -y /etc/ppp/kermit.hup
\r
105 Check to see if `pppd` is still running by executing `/usr/etc/ppp/ppptest`, which should look like this:
\r
109 pid=`ps ax| grep pppd |grep -v grep|awk '{print $1;}'`
\r
110 if [ X${pid} != "X" ] ; then
\r
111 echo 'pppd running: PID=' ${pid-NONE}
\r
113 echo 'No pppd running.'
\r
120 To hang up the modem, execute `/etc/ppp/kermit.hup`, which should contain:
\r
123 set line /dev/tty01 ; put your modem device here
\r
125 set file type binary
\r
126 set file names literal
\r
131 set term bytesize 8
\r
132 set command bytesize 8
\r
143 Here is an alternate method using `chat` instead of `kermit`:
\r
145 The following two files are sufficient to accomplish a `pppd` connection.
\r
147 `/etc/ppp/options`:
\r
152 crtscts # enable hardware flow control
\r
153 modem # modem control line
\r
154 connect "/usr/bin/chat -f /etc/ppp/login.chat.script"
\r
155 noipdefault # remote PPP serve must supply your IP address
\r
156 # if the remote host doesn't send your IP during
\r
157 # IPCP negotiation, remove this option
\r
158 passive # wait for LCP packets
\r
159 domain <your.domain> # put your domain name here
\r
161 : # put the IP of remote PPP host here
\r
162 # it will be used to route packets via PPP link
\r
163 # if you didn't specified the noipdefault option
\r
164 # change this line to <local_ip>:<remote_ip>
\r
166 defaultroute # put this if you want that PPP server will be
\r
167 # your default router
\r
170 `/etc/ppp/login.chat.script`:
\r
172 **Note:** The following should go on a single line.
\r
175 ABORT BUSY ABORT 'NO CARRIER' "" AT OK ATDT<phone.number>
\r
176 CONNECT "" TIMEOUT 10 ogin:-\\r-ogin: <login-id>
\r
177 TIMEOUT 5 sword: <password>
\r
180 Once these are installed and modified correctly, all you need to do is run `pppd`, like so:
\r
186 ### 18.3.3 Using `pppd` as a Server
\r
188 `/etc/ppp/options` should contain something similar to the following:
\r
191 crtscts # Hardware flow control
\r
192 netmask 255.255.255.0 # netmask (not required)
\r
193 192.114.208.20:192.114.208.165 # IP's of local and remote hosts
\r
194 # local ip must be different from one
\r
195 # you assigned to the ethernet (or other)
\r
196 # interface on your machine.
\r
197 # remote IP is IP address that will be
\r
198 # assigned to the remote machine
\r
199 domain ppp.foo.com # your domain
\r
200 passive # wait for LCP
\r
204 The following `/etc/ppp/pppserv` script will tell **pppd** to behave as a server:
\r
208 ps ax |grep pppd |grep -v grep
\r
209 pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
\r
210 if [ "X${pid}" != "X" ] ; then
\r
211 echo 'killing pppd, PID=' ${pid}
\r
214 ps ax |grep kermit |grep -v grep
\r
215 pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
\r
216 if [ "X${pid}" != "X" ] ; then
\r
217 echo 'killing kermit, PID=' ${pid}
\r
221 # reset ppp interface
\r
223 ifconfig ppp0 delete
\r
225 # enable autoanswer mode
\r
226 kermit -y /etc/ppp/kermit.ans
\r
229 pppd /dev/tty01 19200
\r
232 Use this `/etc/ppp/pppservdown` script to stop the server:
\r
236 ps ax |grep pppd |grep -v grep
\r
237 pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
\r
238 if [ "X${pid}" != "X" ] ; then
\r
239 echo 'killing pppd, PID=' ${pid}
\r
242 ps ax |grep kermit |grep -v grep
\r
243 pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
\r
244 if [ "X${pid}" != "X" ] ; then
\r
245 echo 'killing kermit, PID=' ${pid}
\r
249 ifconfig ppp0 delete
\r
251 kermit -y /etc/ppp/kermit.noans
\r
254 The following **kermit** script (`/etc/ppp/kermit.ans`) will enable/disable autoanswer mode on your modem. It should look like this:
\r
257 set line /dev/tty01
\r
259 set file type binary
\r
260 set file names literal
\r
265 set term bytesize 8
\r
266 set command bytesize 8
\r
275 out ATS0#1\13 ; change this to out ATS00\13 if you want to disable
\r
282 A script named `/etc/ppp/kermit.dial` is used for dialing and authenticating on the remote host. You will need to customize it for your needs. Put your login and password in this script; you will also need to change the input statement depending on responses from your modem and remote host.
\r
286 ; put the com line attached to the modem here:
\r
288 set line /dev/tty01
\r
290 ; put the modem speed here:
\r
293 set file type binary ; full 8 bit file xfer
\r
294 set file names literal
\r
299 set term bytesize 8
\r
300 set command bytesize 8
\r
303 set dial hangup off
\r
304 set carrier auto ; Then SET CARRIER if necessary,
\r
305 set dial display on ; Then SET DIAL if necessary,
\r
307 set input timeout proceed
\r
308 set input case ignore
\r
309 def \%x 0 ; login prompt counter
\r
312 :slcmd ; put the modem in command mode
\r
313 echo Put the modem in command mode.
\r
314 clear ; Clear unread characters from input buffer
\r
316 output +++ ; hayes escape sequence
\r
317 input 1 OK\13\10 ; wait for OK
\r
318 if success goto slhup
\r
323 if fail goto slcmd ; if modem doesn't answer OK, try again
\r
325 :slhup ; hang up the phone
\r
326 clear ; Clear unread characters from input buffer
\r
328 echo Hanging up the phone.
\r
329 output ath0\13 ; hayes command for on hook
\r
331 if fail goto slcmd ; if no OK answer, put modem in command mode
\r
333 :sldial ; dial the number
\r
336 output atdt9,550311\13\10 ; put phone number here
\r
337 assign \%x 0 ; zero the time counter
\r
340 clear ; Clear unread characters from input buffer
\r
341 increment \%x ; Count the seconds
\r
343 if success goto sllogin
\r
344 reinput 1 {NO CARRIER\13\10}
\r
345 if success goto sldial
\r
346 reinput 1 {NO DIALTONE\13\10}
\r
347 if success goto slnodial
\r
349 if success goto slhup
\r
351 if success goto slhup
\r
352 if < \%x 60 goto look
\r
356 assign \%x 0 ; zero the time counter
\r
358 echo Looking for login prompt.
\r
361 increment \%x ; Count the seconds
\r
362 clear ; Clear unread characters from input buffer
\r
365 ; put your expected login prompt here:
\r
367 input 1 {Username: }
\r
368 if success goto sluid
\r
370 if success goto slhup
\r
372 if success goto slhup
\r
373 if < \%x 10 goto slloop ; try 10 times to get a login prompt
\r
374 else goto slhup ; hang up and start again if 10 failures
\r
378 ; put your userid here:
\r
380 output ppp-login\13
\r
381 input 1 {Password: }
\r
383 ; put your password here:
\r
385 output ppp-password\13
\r
386 input 1 {Entering SLIP mode.}
\r
391 echo \7No dialtone. Check the telephone line!\7
\r
396 ; comment-start: "; "
\r
397 ; comment-start-skip: "; "
\r
404 CategoryHandbook-pppandslip
\r