Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [256]

By Root 1194 0
by '' as the send string). After this, chat waits for the prompt ogin: before sending the username, and waits for assword: before sending the password.

The various send strings starting with AT in the previous example are simply Hayes-modem-standard modem control strings. The manual that came with your modem should explain their usage; this is not specific to Linux or any other operating system. As one example, using a comma in a phone number indicates that the modem should pause before sending the following digits; one might use ATDT9,,,555-1212 if a special digit (9 in this case) must be dialed to reach an outside line.

Note that this is a very simple chat script that doesn't deal with timeouts, errors, or any other extraordinary cases that might arise while you're attempting to dial into the ISP. See the chat manual pages for information on how to spruce up your script to deal with these cases. Also, note that you need to know in advance what prompts the ISP's server will use (we assumed login and password). There are several ways of finding out this information; possibly, the ISP has told you this information in advance, or supplied a handshaking script for another system such as Windows 95 (which uses a mechanism very similar to chat). Otherwise, you can dial into the ISP server "by hand," using a simple terminal emulator such as minicom or seyon. The manpages for those commands can help you do this.

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, you do this 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 13-1 shows the options supported by pppd. You almost certainly won't need all of them.

Table 13-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 following 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

Return Main Page Previous Page Next Page

®Online Book Reader