Originally Published: Friday, 31 August 2001 Author: Randy le Jeune
Published to: learn_articles_firststep/General Page: 1/1 - [Printable]

Connecting To The Internet With Linux

Sometimes getting on line with Linux can be challenging, especially for the new users. This article from Linux.com Learn section clears up the line.

options File   Page 1 of 1  

The /etc/ppp/options File

The options file is used to specify certain options (big surprise there!) for your method of connection. Mine looks like this:


### 
# /etc/ppp/options - options for pppd 
# 
#!/bin/sh 
/dev/ttyS0 
115200 
connect /etc/ppp/earthlink-connect 
user ELN/gsibbery 
lock 
crtscts 
defaultroute 
noipdefault 
The first line is the serial port that your modem is on. My modem is on serial port ttyS0 (or COM1 in Windows). By the way, make sure you only have one device specified as your modem. Some people get confused and try to use both /dev/ttyS0 and /dev/modem as the device file for their modem. This will produce an error. It would be OK, however, to make /dev/modem a symbolic link (shortcut) to refer to your modem. The "connect" line specifies the name and location of the chat script that I will describe below. You may have to figure which one yours is on by trial and error, or with t a tool like kermit or minicom. The next line specifies the speed at which the transmissions are to take place . . . I have a Rockwell 56K modem and the standard speed for a 56K is 115200. The "lock" option writes out a lock file to the /var/lock directory that ensures that no one else can use the modem while I am using it. Linux does this with a number of devices; if you use a device like a modem once and then find that when you try to dial out a second time, you get an error message, chances are that your modem lock file is not being deleted when you relinquish control of the device. This may seem a bit uncalled for, but remember that Linux is a multi-user system -- only one person can have exclusive access to some devices at a time. My ISP uses a version of PAP and so I need the line "user {username}". If your ISP uses a different authentication protocol, you may not need this line. The line "crtscts" means that the modem is using hardware flow control (this is almost always true under Linux). The "defaultroute" option adds a default route to your local routing table using the remote IP address as the gateway. The "noipdefault" line is used because I connect using a modem and not a cable, and my machine does not have one fixed IP address, but is assigned one from a pool of available IP addresses each time I dial in to Earthlink. If you have problems connecting, then place "debug" at the end of this file and it will write out error messages to the /var/log/ppp log and if you read over it, you will get some idea of what is going wrong. Once you've found the problem, however, remove the "debug" line from this file or it will keep writing out messages to your log file and it will get larger and larger, taking up more space without performing any useful function. Your /var/log/ppp file should look something like this:

Mar 13 19:15:02 www pppd[1071]: Script /etc/ppp/ip-down started (pid 1248)
Mar 13 19:15:02 www ppp-child[1070]: got Script /etc/ppp/ip-down started (pid 1248)
Mar 13 19:15:02 www pppd[1071]: sent [LCP TermReq id=0x2 "User request"]
Mar 13 19:15:02 www pppd[1071]: Script /etc/ppp/ip-down finished (pid 1248), status = 0x7f00
Mar 13 19:15:02 www ppp-child[1070]: got Script /etc/ppp/ip-down finished (pid 1248), status = 0x7f00
Mar 13 19:15:02 www pppd[1071]: rcvd [LCP TermAck id=0x2]
Mar 13 19:15:02 www pppd[1071]: Connection terminated.
Mar 13 19:15:02 www ppp-child[1070]: got Connection terminated.
Mar 13 19:15:02 www pppd[1071]: Connect time 35.6 minutes.
Mar 13 19:15:02 www ppp-child[1070]: got Connect time 35.6 minutes.
Mar 13 19:15:02 www pppd[1071]: Sent 178091 bytes, received 3120405 bytes.
Mar 13 19:15:02 www ppp-child[1070]: got Sent 178091 bytes, received 3120405 bytes.
Mar 13 19:15:02 www pppd[1071]: Exit.
Mar 13 19:15:02 www ppp-child[1070]: PPP daemon died (exited)
Mar 13 19:15:02 www ppp-child[1070]: restoring resolv.conf
Mar 13 19:15:02 www ppp-envoy[1068]: reopen and hangup /dev/modem
Mar 13 19:15:02 www ppp-envoy[1068]: chat_next(0)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_set_timeout(10)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_message(107, "Hanging up")
Mar 13 19:15:02 www ppp-envoy[1068]: chat_pause(50)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_next(3)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_send("+++")
Mar 13 19:15:02 www ppp-envoy[1068]: chat_pause(50)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_next(5)
Mar 13 19:15:02 www ppp-envoy[1068]: chat_send("ATH")
Mar 13 19:15:02 www ppp-envoy[1068]: chat_expect("OK")
Mar 13 19:15:02 www ppp-envoy[1068]: read error from modem
Mar 13 19:15:02 www ppp-envoy[1068]: terminating 1070
Mar 13 19:15:02 www inetd[513]: pid 1068: exit status 1

Although slopping through this output may not look like the most enticing of activities, it usually will give you some hints as to where you went wrong, or whether the authentication server was expecting something that it didn't receive, and may give you the chance to make allowances for it, or to try something else. (By the way, you are generally best off by using as few of these "options" as is necessary to get your PPP connexion to work . . . if you don't need it, don't use it!)

The Chat Script File

The chat script is the file that actually does the handshaking with your ISP. Unfortunately, it is rather difficult to say exactly what information you need in this file as the details depend somewhat on your ISP. This script can have a variety of names, but is located in the /etc/ppp directory. The name of this chat script will need to be placed in your options file after the "connect" command (as shown above). I use Earthlink as my ISP, so I call my chat script earthlink-connect, but I could have chosen any name I wanted to as long as I specified it in the options file. Your ISP may be of some help in telling you what their authentication daemon expects to see in this file -- you may want to ask them whether their server requires the use of a script with certain specific expect/send pairs (what you send must be what the authenticating server expects to receive -- otherwise the server won't understand the information you are sending to it) -- if so, ask them to specify exactly what they are, so that you can configure your script correctly. Again, do not be surprised if you are given some incorrect information -- this sometimes requires a good bit of trial and error in order to figure out exactly what the server expects. by the way, this was the most annoying aspect of the whole operation to me, but once you figure out the correct options to be used, you'll find that it was rather simple all along. These expect/send pairs represent command responses that must be passed by the script in order to turn on the PPP server at the ISP but it usually looks something like this:

#!/bin/sh
# earthlink-connect: a script for dialing into Earthlink
exec /usr/sbin/chat -v
TIMEOUT 120
ABORT BUSY
ABORT 'NO CARRIER'
'' ATZ
OK ATDT344-0514
CONNECT ''
ogin: ELN/gsibbery
assword: topsecret

This probably looks a little mysterious, so let me try to explain it a little. The crunches (#) signify that the line is a comment. The "exec /usr/sbin/chat -v" line means that the program called chat, located in /usr/sbin will be executed (this is necessary for connexion to take place). The -v option stands for verbose -- this specifies that any output in the logs will be more easily readable by humans -- extremely helpful when reading and trying to troubleshoot the connexion by reading the message logs. The next few lines deal with the modem. "TIMEOUT" is the time (in seconds) before the dial-up attempt is aborted (OK, I'll admit that two minutes is a bit excessive, but if you have problems, you may want to increase the number . . . the default is usually like 30 seconds or something -- usually, but not always.). The next two lines tell the chat program to "abort" the attempted dial-up if the phone line is busy or if there is no dial tone. The next line resets the modem to the factory defaults. The next line actually dials the ISP phone number (keep in mind that this number can change with little warning). If this line doesn't work, you may want to check your ISP's dial-up number, or if you have a pulse rather than a tone telephone line, replace the "ATDT" with "ATPT". I don't think the hyphen separating the two sections of the number is necessary . . . remember to include the area code if you are dialing long-distance. The next line is the instruction to actually complete the connexion, and the next two lines are my login and password (don't try using it as I have changed them for security purposes!). With Earthlink, you need to prefix ELN/ to your username -- this is just one of the peculiarities of dealing with that ISP; this is because the Earthlink server that I dial into is an Windows NT server and it requires that you put the domain name before your username and Earthlink's domain name happens to be "ELN". Others may not require this, or may expect something different, so try to find out what your ISP expects. The reason the initial letter is left off of "login" and "password" is to allow for the fact that your ISP may use upper-case or lower-case initial letters for these words. By omitting the first letter, you avoid this difficulty. Again, there may be some difficulty here, as your ISP may expect "Name" or "userid" instead of "login". If you try a number of these and nothing works, ask them and find out. mentioning "AOL" in your conversation with a rep often works wonders, by the way.

If you try to connect, but are unsuccessful, add the "debug" line at the end of yout /etc/ppp/options file like I mentioned above, then check your /var/log/ppp and /var/log/messages files. If you see something like "auth pap" or "auth chap", then you need to use those authentication protocols. CHAP and PAP are "authentication protocols" which determine that you are really the person who should be using your account. Your pap-secrets and chap-secrets files are located in the /etc/ppp directory and should look something like this (with the appropriate username and password, of course).

#!/bin/sh
# /etc/pap-secrets
#username password
ELN/gsibbery topsecret

I think I should mention that there are many versions of each of these protocols and this might not work for each and every one, and of course some ISP's may require you to log on using more than one of these authentication schemes, so if none of this works, ask them.

The ppp-on File

One last files that you have to add is your ppp-on file, which will be located in your /usr/sbin or / directory. This is what actually turns on PPP. I couldn't start my PPP services without this file, and as it turned out, this was my main problem in getting connected. The same rules apply as before, but you need to know the subnet mask of your ISP (most are class "C" masks nowadays; that is, 255.255.255.0).

TELEPHONE=344-0514
ACCOUNT=ELN/gsibbery
PASSWORD=topsecret
LOCAL_IP=
REMOTE_IP=0.0.0.0
NETMASK=255.255.255.0

The /etc/hosts File

Normally the /etc/hosts file isn't used for much if you have a nameserver, and if you don't have a nameserver, you probably won't be going very far, as one single hosts file cannot possibly take the place of the worldwide DNS database. But you should put the name of your local host machine in here and the internal loopback address. Any aliases that you use in your other configuration files (such as /etc/hosts.deny) must also be specified in here.




options File   Page 1 of 1