chat
It's far more easey to let the pppd
do all the setting of
addresses and routes. Furthermore, it can even do the dialing so that
you can start up the PPP-connection with a single command.
chat
-script, that does send the
modem the dial-command, and then log into your terminal server, giving
it your username and password, and then do the right steps to start the
PPP connection. As especially the last step is highly dependent on your
provider's terminal/modem-server, no general rules can be told about
this here. As an example, I'll use our server who asks for a username
('Username>
'), a password ('Password>
') and the offer a
menu from where you can choose to start PPP (among other things). One
chooses entry #20 from the menu to start PPP on the appropriate prompt
('... use arrow keys:
').
With this in mind, put the following in `/etc/ppp/chat':
ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATD09419431320 sername>--sername> MYUSERNAME assword> MYPASSWORD 'or use arrow keys:' 20The first two lines tell chat to abort if the line's busy or there's no carrier. It then dials the modem-server (please change this for yours!), which asks for a username and password, and responds with the appropriate values (please change those two, too!), then asks to choose a item from the menu by either entering the numer or by using the arrow keys. We use item #20 here, and it fires up PPP.
pppd
:
In order to let pppd
do all the address negotiation, setting of
routes etc., you'll have to tell it to do so. You do this by entering
the following lines in `/etc/ppp/options':
crtscts defaultroute netmask 255.255.255.0 noipdefault ipcp-accept-local ipcp-accept-remoteThis tells
pppd
to use RTC/CTS handshaking, set the system's
default-route, use the propper netmask and use no default-values for the
local and remote IP-numbers but rather to accept them from the remote
end's pppd
.
Please read pppd
's manpage, as there are a LOT more options, from
which the one or other might be userful for you.
pppd
to do the remaining work:
pppd /dev/tty00 38400 connect "chat -f /etc/ppp/chat"This will first do the dial-in etc., then use the values given in `/etc/ppp/options' to set the local ip-number, fix the routing tables and make everything go fine. This command can be issued by every user, not only root. After starting up the connection, you can put an optional shell-script in `/etc/ppp/ip-up' that does miscellaneous system initialisations, such as starting a web-proxy, exchange mail, fix your `/etc/resolv.conf', etc.
pppd
writes its pid to
`/var/run/ppp0.pid'. If you want to end the PPP-session, just kill
it:
kill `cat /var/run/ppp0.pid`To undo any changes done by the `ip-up' script, you can place another shell-script in `/etc/ppp/ip-down' to e.g. shut down your web proxy, etc.