Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Living Linux

Connecting to the Internet

06/27/2000

There are several ways of connecting a home Linux box to the Internet: Digital Subscriber Line (DSL) service, cable modems, and dial-up connections with ISDN or analog modems. Each of these services has its own hardware and software requirements.

This week's column shows where to get the latest Linux documentation for these services and how to set up and use a PPP ("Point-to-Point Protocol") dial-up connection -- long the de facto means of connecting a computer to the Internet over a dial-up line.

Getting the HOWTOs

To get up-to-date, detailed instructions for using these services on Linux-based systems, the relevant HOWTOs published by the Linux Documentation Project remain the definitive guides:

They're installed on most Linux systems as compressed text files in either the /usr/doc/HOWTO or /usr/share/doc/HOWTO directory; you can read them with the zless tool.

Setting up a dial-up PPP connection

Here's how to configure PPP for a regular dial-up connection, where your system is assigned a dynamic IP address (the norm for home Internet access). You'll have to be root (the superuser) to edit the PPP configuration files, and you'll need the standard connection information from your ISP: the dial-up number to use, the IP addresses for their nameservers, and your username and password for accessing their system.

First, customize the file /etc/chatscripts/provider:


ABORT        BUSY
ABORT        "NO CARRIER"
ABORT        VOICE
ABORT        "NO DIALTONE"
""           ATDT5551010,,
ost         PPP
ogin        smith
word         \qsecret\q

In this example, the ISP's dial-up number is "5551010." (Some systems need one or two commas after the number to signify pauses for the modem; only do this if you cannot get a good connection with just the telephone number in this space.) The username is "smith" and the password, which appears between two "\q" strings, is "secret." The line above the username is the "host" line: this is an optional line used with some ISPs whose connection line contains a choice of services that you must select before entering your username and password. (Some ISPs offer SLIP and shell access along with the standard PPP.)

Next, edit the file /etc/ppp/peers/provider so that it contains these lines:


connect "/usr/sbin/chat -v -f /etc/chatscripts/provider"
defaultroute /dev/modem 57600 persist

The last line in this file should include the device name of the modem to use and the maximum connect speed to try; the example above uses /dev/modem as the device name of the modem, and 57,600 bps as the maximum connect speed to use. (A rule of thumb is to use the highest connect speed your modem supports; you can always go lower when a connection is made but you can never raise the speed above what is given here.)

Finally, edit the file /etc/resolv.conf so that it contains the following, using the two nameserver IP addresses given to you by your ISP:


     search .
     nameserver      NAMESERVER ADDRESS 1
     nameserver      NAMESERVER ADDRESS 2

Once you've done these things, you should now be able to start and stop PPP connections to the Internet. (The complete documentation for setting up PPP is in the /usr/share/doc/ppp directory.)

To give a non-root user permission to start and stop PPP, use the adduser tool to give them membership in the "dialout" group.

For example, to add user "leo" to the dialout group, type:


$ adduser leo dialout RET

Controlling PPP connections

After PPP has been installed and configured, use the pon tool to start a PPP connection to the Internet. It calls the number of your ISP with your modem, sends the appropriate login information, and starts the PPP connection.

To start a PPP connection, type:


$ pon RET

To make PPP automatically start when the system first boots, rename the file /etc/ppp/no_ppp_on_boot to /etc/ppp/ppp_on_boot.

To output the last few lines of the PPP logfile, type plog. This is useful to check the progress of your PPP connection when it first dials.

Use the poff tool to stop a PPP connection. It disconnects from your ISP and hangs up the modem.

To stop a PPP connection, type:


$ poff RET

Next week: tips for browsing the Web on a Linux box.

Michael Stutz was one of the first reporters to cover Linux and the free software movement in the mainstream press.


Read more Living Linux columns.

Copyright © 2009 O'Reilly Media, Inc.