Before you start, you need to know the following pieces of information:
The ISP dialin account phone number
Your ISP username and password
The IP address of the ISP's domain name server
Your ISP should have told you this information when you established
the account.
In addition, you might need to know the following:
The IP address of the ISP's server
The IP address of your system (if not dynamically assigned by the ISP)
The subnet mask you should use
These last three items can usually be determined automatically during the
PPP connection setup; however, occasionally this negotiation does not work
properly. It can't hurt to have this information in case you need it.
15.2.1.3.2. Starting up pppd
Now, we're ready to configure the pppd daemon to initiate
the PPP connection using the chat script we just wrote.
Generally, this is done by writing another shell script that
invokes pppd with a set of options.
The format of the pppd command is:
pppd device-name baudrate options
Table 15-1 shows the options
supported by pppd. You almost certainly won't need
all of them.
Table 15-1. Common pppd Options
Option |
Effect |
lock |
Locks the serial device to restrict access to pppd. |
crtscts |
Uses hardware flow control. |
noipdefault |
Doesn't try to determine the local IP address from the hostname. The IP is assigned by the remote system. |
user username |
Specifies the hostname or username for PAP or CHAP identification. |
netmask mask |
Specifies the netmask for the connection. |
defaultroute |
Adds a default route to the local system's routing table, using the
remote IP address as the gateway. |
connect command |
Uses the given command to initiate the
connection. pppd assumes this script is in
/etc/ppp. If not, specify the full
path of the script. |
local_IP_address: remote_IP_address |
Specifies the local and/or remote IP addresses. Either or both of these
could be 0.0.0.0 to indicate that the address should be assigned by the
remote system. |
debug |
Logs connection information through the syslog daemon. |
It is common to invoke the pppd command from a shell script.
Edit the file /etc/ppp/ppp-on and add the following lines:
#!/bin/sh
# the ppp-on script
exec /usr/sbin/pppd /dev/modem 38400 lock crtscts noipdefault \
defaultroute 0.0.0.0:0.0.0.0 connect my-chat-script
As with the my-chat-script file in the earlier example, be sure
this is executable and watch out for extra characters after a
backslash at the end of a line.
With this script in place, it should be possible to connect to the ISP
using the
command:
% /etc/ppp/ppp-on
You need not be
root to execute this command. Upon running this script,
you should hear your modem dialing, and if all goes well, after a
minute PPP should be happily connected. The
ifconfig command should report an entry for
ppp0 if PPP is up and running:
# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0
UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
ppp0 Link encap:Point-to-Point Protocol
inet addr:207.25.97.248 P-t-P:207.25.97.154 Mask:255.255.255.0
UP POINTOPOINT RUNNING MTU:1500 Metric:1
RX packets:1862 errors:0 dropped:0 overruns:0 frame:0
TX packets:1288 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
Memory:73038-73c04
Here, we can see that PPP is up, the local IP address is 207.25.97.248,
and the remote server IP address is 207.25.97.154.
If you wish to be notified when the PPP connection is established (the
ppp-on script returns immediately), add the
following line to /etc/ppp/ip-up :
/usr/bin/wall "PPP is up!"
/etc/ppp/ip-up is executed when PPP establishes
an IP connection, so you can use this script to trigger the
wall command when the connection is complete.
Another simple shell script can be used to kill the PPP session. Edit
the file /etc/ppp/ppp-off as follows:
#!/bin/sh
# A simple ppp-off script
kill `cat /var/run/ppp0.pid`
Running /etc/ppp/ppp-off now kills the PPP
daemon and shuts down the modem connection.