-->
Previous | Table of Contents | Next |
The dip program greatly simplifies the connection to a SLIP server. To use it, you need a chat script that contains all the commands used to establish communications with the SLIP server during login. The chat script usually includes your login and password, too, automating the login process.
A sample dip chat script is included in the man pages for dip, so display the man page and read the contents, then save the file (by redirection or copying the man page source) and edit the script. Heres a sample chat script that you can enter by hand if necessary, making sure, of course, that you put in your own data:
# Connection script for SLIP # Fetch the IP address of our target host. main: # Set the desired serial port and speed. port /dev/cua0 speed 38400 # Reset the modem and terminal line. reset # Prepare for dialing. send ATZ1\r wait OK 4 if $errlvl != 0 goto error dial 666-0999 ## Change to your servers number! if $errlvl != 0 goto error wait CONNECT 60 if $errlvl != 0 goto error # We are connected. Log in to the system. login: sleep 3 send \r\n\r\n wait merlin> 20 ## Change to your servers prompt if $errlvl != 0 goto error send login\n wait name: 10 ## Wait username: prompt if $errlvl != 0 goto erro send login_name\n ## Change to your own wait ord: 10 ## Wait password prompt if $errlvl != 0 goto error send my_password\n ## Change to your own! wait merlin> 10 if $errlvl != 0 goto error send slip\n ## Change to suit your server wait SLIP 30 ### Wait for SLIP prompt if $errlvl != 0 goto error get $local remote 10 ## Assumes the server sends your IP.. if $errlvl != 0 goto error ## address as soon as you enter slip. get $remote merlin ## slip server address from /etc/hosts done: print CONNECTED to $remote with address $rmtip we are $local default mode SLIP goto exit error: print SLIP to $host failed. exit: # End dip script
Several different variations of the chat scripts are currently available, including a few on most CD-ROM distributions. If you have access to the Internet, you can find them on some FTP sites or posted on a Linux newsgroup.
PPP is a more powerful protocol than SLIP and is preferable for most uses. PPP functions are divided into two parts; one for the High-Level Data Link Control (HLDC) protocol, which helps define the rules for sending PPP datagrams between the two machines, and one for the PPP daemon called pppd, which handles the protocol once the HLDC system has established communications parameters.
As with SLIP, PPP establishes a modem link between two machines, then hands over the control of the line to PPP. Prior to establishing a PPP link, you must have a loopback driver established. You should also have a name resolution system in operation, even if its the /etc/hosts file or a simple DNS cache-only name server. (See the section called Using DNS for SLIP and PPP later in this chapter.)
If you are letting people dial in to your system using PPP, for security reasons it is best to use PPP with a special user account called PPP. This is not necessary if you are dialing out only, and you can easily use PPP from any user account; but for more secure operation, consider creating a new user just for PPP, especially when allowing dial-ins. First, you need to add a new user to the system. You can use whatever script your operating system normally uses (such as newuser, adduser, or simple editing of the /etc/passwd file).
A sample /etc/passwd entry for the PPP account (with UID set to 201 and GID set to 51) looks like this:
ppp:*:201:51:PPP account:/tmp:/etc/ppp/pppscript
In this case, the account is set with no password (so no one can log in to the account) and because no files are created, a home directory of /tmp is used. The startup program is set to /etc/ppp/pppscript, a file you create with configuration information in it. (You can use any filename instead of pppscript.)
A sample of the pppscript file looks like this:
#!/bin/sh mesg n stty -echo exec pppd -detach silent modem crtscts
The first line forces execution of the script to the Bourne (or bash) shell, regardless of which shell youre running (see Chapter 14, Shell Programming, for more details). The second line turns off all attempts to write to the PPP accounts tty. The stty command on the third line is necessary to stop everything the remote sends from being echoed to the screen again. Finally, the exec command on the last line runs the pppd daemon (which handles all PPP traffic). You will see the pppd daemon and its options later in this section.
Previous | Table of Contents | Next |