Subject: Re: Configuring PPP
To: Dante Profeta <dante@mbox.vol.it>
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
List: netbsd-help
Date: 05/09/1996 13:55:07
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.1@cmsun.cmf.nrl.navy.mil>

>Now, all I understand is that NetBSD have ppp built into the kernel, while
>FreeBSD have ppp also out of the kernel.

Well, that's not exactly true - FreeBSD has both in-kernel ppp and userland
ppp.

>Well, I also, and obviously, read the man about pppd, and now all I know is
>that there are too much options. ;-)
>Pppd tells about some mysterious scripts into /etc/ppp/ but don't tell at all
>how to create them, neither who really need them: pppd? The user, to start and
>stop ppp? :-|
>
>Could anyone please explain me how configure, start and stop a client ppp with
>pap for dial-up connection with dynamic IP?

It's not that hard.  First off, the scripts that the man page mentions are
ones that PPP runs when the link goes up and down.  So you don't need them
unless you want to do something special when the link comes up.  For
example, my ip-up script has this:

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.2@cmsun.cmf.nrl.navy.mil>
Content-Description: My ip-up script

#!/bin/sh
#
# If the net is coming up and we have AFS loaded, re-ping the servers
#
if modstat | grep -q afs\$; then
	/usr/athena/bin/fs checkserver
fi

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.3@cmsun.cmf.nrl.navy.mil>

This runs when the net comes up; it has the effect of "waking up" AFS
so that my machine knows that the AFS servers are now available.

If you want to use dynamic IP (which I am assuming you mean "dynamic PPP",
which connects when the net goes up), that's fairly easy.  Here are my
option files.  Note that I invoke pppd as "pppd file /etc/ppp/options.nrl";
this makes it so pppd doesn't have a big command line, and it lets me
comment stuff.

This is my options file - it has some global stuff which would apply to
all PPP sessions (of which currently there is only one :-) ).  PPP
automatically reads in this file.

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.4@cmsun.cmf.nrl.navy.mil>
Content-Description: Global options file (/etc/ppp/options)

#
# Global PPP options
#

# always lock the device you're using
lock

# By default, don't escape anything
asyncmap 0x00000000

# Check to see if the connection has died recently (this will catch modem
# hangs)
lcp-echo-failure 2
lcp-echo-interval 60

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.5@cmsun.cmf.nrl.navy.mil>

This is my session-specific options file.  My command line causes this to
be read in.

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.6@cmsun.cmf.nrl.navy.mil>
Content-Description: Session specific options file (/etc/ppp/options.nrl)

#
# Options we use when we connect to NRL
#

# hardware flow control
crtscts

# use modem control lines
modem

# Enable a default route
defaultroute

# Use demand-dial
demand
idle 300
persist

# Low MRU/MTU (for interactive traffic)
mru 296
mtu 296

# VJ header compression is broken on the netblazer
-vj

# This filter prevents us from waking up due to the occasional pings that
# AFS does to keep track of it's servers
#
# Sigh.  This is getting rather complicated.  Basically, we filter:
#
# fs "get-time" call (that's what AFS uses to ping fileservers)
# fs RX "ack" packets (AFS sends these occasionally)
# vldb "get-entry-by-name-n" packets (does it on the root volume)
# vldb "probe" packets (uses that to check for down vldb servers)
# vldb RX "ack" packets (AFS sends these occasionally as well)
#
# What a mess!  But amazingly, the expression below optimizes to only
# 18 bpf instructions.
#
active-filter "not (udp and (dst port 7000 and (udp[36:4] = 153 or udp[28] = 2)) or (dst port 7003 and (udp[36:4] = 519 or udp[36:4] = 514 or udp[28] = 2)))"

# This is our login script for NRL
connect "chat -f /etc/ppp/chat.nrl"

# We use tty01
/dev/tty01

# At 57600 baud
57600

# Our IP addresses (we need to put them here because of demand-dial)
134.207.6.17:134.207.6.150

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <5946.831664425.7@cmsun.cmf.nrl.navy.mil>

The magic here is the "demand", "idle 300", and "persist" options.

"demand" tells pppd to only make the connection when it notices traffic
on that line.  "idle 300" tells it to hang up after 5 minutes of idle time.
"persist" tells it to stay around after it hangs up (otherwise pppd will
die when it hangs up the line).  The rest of the stuff in there can be
figured out from the man page.  Note that unless you run AFS, you probably
don't want that nasty active-filter :-)

I don't use PAP, but it seems that it's pretty well explained in the man page.

>There is another thing I don't understand: pppd when started, seems to set
>automatically the IP address assigned from the server (if dynamic), that's ok,
>but I've got an ethernet board with an assigned IP address, how can I tell
>pppd to do an "ifconfig ip-address alias"?

Now if you get your IP address assigned from the remote side, you can't use
dynamic PPP.  But if you just want the remote address assigned to you, then
you can just omit the IP address specification in the config file and
it should figure out everything dynamically (you might also want to look
at the noipdefault and the ipcp-accept-local options in the man page).

You probably don't want to mess with the ethernet board at all.  If you
want your machine to be a router for your local net, set up static
routes pointing to your machine on all other machines, and look at the
"defaultroute" option to pppd.

As for scripts to start and stop ppp, those would be simple.  With starting,
you'd just need to run pppd with whatever arguments you specify.  For
stopping you could just get the pid out of /var/run/ppp0.pid and send pppd
a SIGTERM.

If any of this is unclear, please don't hesitate to ask.

--Ken

------- =_aaaaaaaaaa0--