Connecting through the Serial Interface

Regardless of whether data comes through a modem or from a directly attached terminal, it is handled by the Linux system in the same way. Three programs handle the connection: init, getty, and login.

init is responsible for attaching the getty program to a serial port and for restarting the getty program whenever it terminates. You saw an example of this in the description of the inittab file in Chapter 1.

getty monitors the serial port. When getty detects a carrier signal on the port, it displays the login: prompt. It reads in the user's name and uses it to invoke login. For example if getty received norman in response to the login prompt, it would issue the command login norman.

login then prompts the user for a password, and checks the password using the appropriate authentication scheme. One of a number of schemes can be selected during the initial installation, as described in Appendix A, "Installing Linux." For example, the password might be checked against the encrypted password in the /etc/passwd or /etc/shadow file. The Linux user is given a few tries to enter the correct password. After the password is verified as correct, the UID and GID associated with the username are assigned to the tty device, and the following environment variables are set:

HOME This variable defines the user's home directory. login takes the value from the / etc/passwd file.

SHELL This variable defines the user's login shell. login takes the value from the /etc/ passwd file.

LOGNAME This variable defines the name by which the user is identified in the system log. login uses the username passed to it by getty.

PATH This variable defines the execution path. login defaults to a path of /usr/local/bin:/ bin:/usr/bin.

MAIL This variable defines the path to the user's mail file. login uses the path /var/mail/spool/username, where username is the name passed to login by getty.

TERM This variable identifies the terminal type. login keeps the TERM environment variable set by getty. The value of TERM will be a valid terminal type from the /etc/termcap file.

After these variables are set, login starts the shell identified in the user's /etc/passwd entry. The shell processes the initialization files that it finds in the user's home directory. These initialization files, such as .bash_profile and .bashrc for the bash shell, permit users to set their own environment variables; for example, to define a more complete execution path. Finally, the shell issues the command prompt to the user, and the user has access to the system.

All of these processes and services happen automatically and require almost no configuration on your part beyond creating a user account for the user and configuring the modem to answer the telephone. The basic Linux system comes with the capability to support terminal connections through serial ports. If you have ever configured dial-up services on other PC operating systems, you'll appreciate what an advantage this is.

Of course, even on a Linux system, things don't always work smoothly. Linux comes with some terminal-emulation programs such as seyon and minicom that can be used to troubleshoot modems and serial links.

Note See Chapter 13, "Troubleshooting," for information on troubleshooting with minicom. The support for serial communications that is built into Linux is the foundation for running TCP/ IP

over a serial line. The next section covers just that. Running TCP/IP Over a Serial Port

Of much greater utility than the capability to connect a terminal to your server's serial port is the capability to run TCP/IP over a serial port. Doing so allows you to run TCP/IP over a telephone line with a modem. This is, of course, the way that most people connect to the Internet through a local ISP. But it is also a way for you to provide connectivity into the Internet or your enterprise network for a remote field office or for users working at home.

Point-to-Point Protocol (PPP) provides the framing mechanism for sending IP datagrams over a telephone line. PPP uses a three-layered architecture to accomplish this:

Data Link layer PPP uses a High-Level Data Link Control (HDLC) protocol to provide reliable data delivery over any type of serial line.

Link Control layer A Link Control Protocol (LCP) was specifically developed for PPP. It opens and closes connections, monitors link quality, and negotiates the link configuration parameters.

Network Control layer PPP is designed to carry a wide variety of network protocols. Protocols in this layer provide the control information that is necessary to customize the PPP link for the type of network traffic it is carrying. The network control protocol for TCP/IP is the Internet Protocol Control Protocol (IPCP).

Properly configuring a PPP service requires that all of these layers are correctly installed as well, and that the serial port and modem over which the traffic passes are properly configured. The remainder of this chapter looks at how these things are done on a Linux system.

Was this article helpful?

0 0

Post a comment