[ Pobierz całość w formacie PDF ]
.The secondcommand turns off all attempts to write to the ppp account's tty.The stty command is necessary to stop everything the remote sends beingechoed again.Finally, the exec command runs the pppd daemon (whichhandles all PPP traffic).You will see the pppd daemon and the options laterin this section.Dialing Out: chatPPP requires you to establish a modem connection to the remote machine beforeit can take over and handle the communications.There are several utilities availableto do this, the most commonly used of which is chat.The chat programis popular because it uses a scripting style similar to that used by UUCP.(See Chapter44, "UUCP.")To use chat, you have to assemble a command line that looks almost thesame as a UUCP /etc/Systems file entry.For example, to call a remote machinewith a Hayes-compatible modem (using the AT command set) at the number 555-1234,you use the following command.It is all formatted as a chat script, UUCPstyle:chat "" ATZ OK ATDT5551234 CONNECT "" ogin: ppp word: secret1If you read the UUCP chapter, this may look familiar.If not, all the entriesare in a "send-expect" format, with what you send to the remote specifiedafter what you receive from it.The chat script always starts with an expectstring, which you must set to be empty because the modem won't talk to you withoutany signal to it.After the empty string, send the ATZ (reset) command,wait for an OK back from the modem, and then send the dial command.Once a CONNECT message is received back from the modem, the loginscript for the remote machine is executed--you send a blank character, wait for theogin: (login) prompt, send the login name ppp, wait for the word:(password) prompt, and then send your password.After the login is complete, chatterminates but leaves the line open.If you want to see all the activity that goes on with the chat program,you can force all messages to the syslog daemon for future study.The -voption forces the messages to syslog, so the command would be as follows:chat -v "" ATZ OK ATDT5551234 CONNECT "" ogin: ppp word: secret1If the other end of the connection doesn't answer with a login scriptas soon as its modem answers, you may have to force a Break command downthe line to jog the remote end.This is done in the same way as with UUCP:chat -v "" ATZ OK ATDT5551234 CONNECT "" ogin:-BREAK-ogin: ppp word: secret1There's a security problem with this type of chat entry, because anyuser doing a ps -ef command will see the entire command line (with its passwords).If you are the only user of your system, this isn't a concern, but to save yourselfany problems, you can embed the script portion of the command in a file and readthe file into chat.Then, the script will not appear on a ps output.To call a file for use with chat, use the -f option:chat -f chat_fileThe chat_file will contain the string:"" ATZ OK ATDT5551234 CONNECT "" ogin: ppp word: secret1The chat script can help you detect common error conditions, such asa line busy or no connection established.The messages from your modem (Hayes usesBUSY and NO CARRIER respectively) are embedded in thechat script with the ABORT option, which enables you to exit fromthe chat script gracefully if one of these error conditions occurs.To handle these abort conditions, you embed the chat keyword ABORTfollowed by the message that should trigger an abort, prior to your normal chatscript.For example, to modify the chat script above to abort on a BUSYor NO CARRIER message from the modem, the script would look likethis:ABORT BUSY ABORT `NO CARRIER' "" ATZ OK ATDT5551234 CONNECT "" ogin: ppp word: secret1We needed two ABORT commands because each takes only one argument.Therest of the chat script is as usual.Note the need to put quotation marksaround the NO CARRIER message because the space in the middle would confusethe script otherwise.Running pppdTo set up a PPP connection, you need to invoke the pppd daemon
[ Pobierz całość w formacie PDF ]